-
Notifications
You must be signed in to change notification settings - Fork 9
/
fix_cursorhold_nvim.vim
47 lines (40 loc) · 1.22 KB
/
fix_cursorhold_nvim.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
" Maintainer: Antoine Madec <[email protected]>
if exists('g:loaded_fix_cursorhold_nvim')
finish
else
let g:loaded_fix_cursorhold_nvim = 'yes'
endif
let g:cursorhold_updatetime = get(g:, 'cursorhold_updatetime', &updatetime)
let g:fix_cursorhold_nvim_timer = -1
set eventignore+=CursorHold,CursorHoldI
augroup fix_cursorhold_nvim
autocmd!
autocmd CursorMoved * call CursorHoldTimer()
autocmd CursorMovedI * call CursorHoldITimer()
augroup end
function CursorHold_Cb(timer_id) abort
if v:exiting isnot v:null
return
endif
set eventignore-=CursorHold
doautocmd <nomodeline> CursorHold
set eventignore+=CursorHold
endfunction
function CursorHoldI_Cb(timer_id) abort
if v:exiting isnot v:null
return
endif
set eventignore-=CursorHoldI
doautocmd <nomodeline> CursorHoldI
set eventignore+=CursorHoldI
endfunction
function CursorHoldTimer() abort
call timer_stop(g:fix_cursorhold_nvim_timer)
if mode() == 'n'
let g:fix_cursorhold_nvim_timer = timer_start(g:cursorhold_updatetime, 'CursorHold_Cb')
endif
endfunction
function CursorHoldITimer() abort
call timer_stop(g:fix_cursorhold_nvim_timer)
let g:fix_cursorhold_nvim_timer = timer_start(g:cursorhold_updatetime, 'CursorHoldI_Cb')
endfunction