Fix word under cursor updating on toggle

This commit is contained in:
Talia 2018-07-18 10:40:03 +02:00
parent 9d50868efa
commit 7a3be20539

10
vimrc
View file

@ -736,6 +736,7 @@ digraph ss 223
command! HLProgress syntax match Comment /\_.*\ze\n.*\%#/
nnoremap <leader>h :call <SID>toggleWUC()<CR>
function! s:updateWUC()
if exists("b:hlwuc")
if b:hlwuc > 1
@ -747,10 +748,10 @@ function! s:updateWUC()
else
let hl = "Underlined"
endif
let str = "\\<".escape(expand("<cword>"), "\\")."\\>"
let b:hlwuc = matchadd(hl, str)
"echom str
let l:str = "\\<".escape(expand("<cword>"), "\\")."\\>"
let b:hlwuc = matchadd(hl, l:str)
endfunc
function! s:toggleWUC()
augroup hlwuc
if exists("b:hlwuc")
@ -760,11 +761,12 @@ function! s:toggleWUC()
end
unlet b:hlwuc
else
call <SID>updateWUC()
autocmd CursorMoved <buffer> call <SID>updateWUC()
autocmd CursorMovedI <buffer> call <SID>updateWUC()
call <SID>updateWUC()
endif
augroup END
redraw
endfunction
" Autosave when vim loses focus :)