Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions autoload/cursorword.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ function! cursorword#highlight() abort
highlight default CursorWord term=underline cterm=underline gui=underline
endfunction

function! cursorword#clear() abort
if get(w:, 'cursorword_match')
silent! call matchdelete(w:cursorword_id)
let w:cursorword_match = 0
let w:cursorword_state = []
endif
endfunction

let s:alphabets = '^[\x00-\x7f\xb5\xc0-\xd6\xd8-\xf6\xf8-\u01bf\u01c4-\u02af\u0370-\u0373\u0376\u0377\u0386-\u0481\u048a-\u052f]\+$'

function! cursorword#matchadd(...) abort
Expand All @@ -37,11 +45,7 @@ let s:delay = get(g:, 'cursorword_delay', 50)
if has('timers') && s:delay > 0
let s:timer = 0
function! cursorword#cursormoved() abort
if get(w:, 'cursorword_match')
silent! call matchdelete(w:cursorword_id)
let w:cursorword_match = 0
let w:cursorword_state = []
endif
call cursorword#clear()
call timer_stop(s:timer)
let s:timer = timer_start(s:delay, 'cursorword#timer_callback')
endfunction
Expand Down
4 changes: 4 additions & 0 deletions plugin/cursorword.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ augroup cursorword
call cursorword#highlight()
autocmd WinEnter,BufEnter * call cursorword#matchadd()
endif
autocmd WinLeave,BufLeave *
\ if get(g:, 'cursorword_clear_on_leave', 0) |
\ call cursorword#clear() |
\ endif
autocmd ColorScheme * call cursorword#highlight()
autocmd CursorMoved,CursorMovedI * call cursorword#cursormoved()
autocmd InsertEnter * call cursorword#matchadd(1)
Expand Down