From 22501182ce7ddfce7ab25420100cb5b7819e2b12 Mon Sep 17 00:00:00 2001 From: druckdev Date: Mon, 26 Apr 2021 17:56:15 +0200 Subject: [PATCH] vim: Use timer instead of autocommand for autoread --- .config/vim/vimrc.d/70-functions.vim | 8 ++++++++ .config/vim/vimrc.d/80-autocommands.vim | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.config/vim/vimrc.d/70-functions.vim b/.config/vim/vimrc.d/70-functions.vim index b93492d..b91a7f6 100644 --- a/.config/vim/vimrc.d/70-functions.vim +++ b/.config/vim/vimrc.d/70-functions.vim @@ -7,3 +7,11 @@ function! CycleSpellLang() set spelllang=en endif endfunction + +" Check time every second to read file changes. +if (exists('+autoread') && &autoread) + function! CheckTime(timer) + checktime + endfunc + execute timer_start(1000, 'CheckTime', {'repeat': -1}) +endif diff --git a/.config/vim/vimrc.d/80-autocommands.vim b/.config/vim/vimrc.d/80-autocommands.vim index 2a0888b..be01ceb 100644 --- a/.config/vim/vimrc.d/80-autocommands.vim +++ b/.config/vim/vimrc.d/80-autocommands.vim @@ -53,9 +53,3 @@ else autocmd VimLeave * silent !echo -ne "\e[5 q" endif endif - -" Read file changes when cursor is not moved for &updatetime ms and then move -" cursor to restart the timer -if (exists('+autoread') && &autoread) - autocmd CursorHold * checktime | call feedkeys('hl') -endif