diff options
author | Robin Obůrka <r.oburka@gmail.com> | 2017-08-22 20:51:56 +0200 |
---|---|---|
committer | Robin Obůrka <r.oburka@gmail.com> | 2017-09-18 20:33:45 +0200 |
commit | 89a548709fcfada6350580d775036fd6282489dd (patch) | |
tree | 42a24c3db7a0fd3dcdd4da385562e73bf0a00857 | |
parent | Add nerdtree git plugin (diff) | |
download | vim_sync-89a548709fcfada6350580d775036fd6282489dd.tar.xz |
Update HiCursorWords - once more
-rw-r--r-- | .vim/hicursorwords.vim | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/.vim/hicursorwords.vim b/.vim/hicursorwords.vim index 4d47474..ba233ba 100644 --- a/.vim/hicursorwords.vim +++ b/.vim/hicursorwords.vim @@ -25,6 +25,17 @@ " g:HiCursorWords_debugEchoHiName = 0 " If not 0, echoes the highlight group name under the cursor. " +" g:HiCursorWords_visible = 1 +" Set to 0 in vimrc to startup with HiCursorWords disabled +" +" g:HiCursorWords_style +" Set cursor-word style +" +" or +" +" g:HiCursorWords_linkStyle +" Set cursor-word style for linking +" " Hightlight groups: " " (Do :highlight! as you like.) @@ -32,6 +43,10 @@ " WordUnderTheCursor " " +" Source this file and put the following line in your vimrc to +" toggle auto-highlighting of the word under the cursor. +"map <F5> :call HiCursorWords_toggle()<cr> + if !exists('g:HiCursorWords_delay') let g:HiCursorWords_delay = 200 @@ -45,15 +60,30 @@ if !exists('g:HiCursorWords_debugEchoHiName') let g:HiCursorWords_debugEchoHiName = 0 endif +if !exists('g:HiCursorWords_visible') + let g:HiCursorWords_visible = 1 +endif + +if !exists('g:HiCursorWords_style') && !exists('g:HiCursorWords_linkStyle') + let g:HiCursorWords_linkStyle='Underlined' +endif -highlight! link WordUnderTheCursor Underlined +if g:HiCursorWords_visible + if exists('g:HiCursorWords_style') + exec 'highlight! WordUnderTheCursor ' . g:HiCursorWords_style + elseif exists('g:HiCursorWords_linkStyle') + exec 'highlight! link WordUnderTheCursor '. g:HiCursorWords_linkStyle + endif +else + highlight! link WordUnderTheCursor NONE +endif augroup HiCursorWords autocmd! - autocmd CursorMoved * call s:HiCursorWords__startHilighting() + autocmd CursorMoved,CursorMovedI * call s:HiCursorWords__startHilighting() + autocmd WinLeave * call s:HiCursorWords__stopHilighting() augroup END - function! s:HiCursorWords__getHiName(linenum, colnum) let hiname = synIDattr(synID(a:linenum, a:colnum, 0), "name") let hiname = s:HiCursorWords__resolveHiName(hiname) @@ -99,7 +129,7 @@ function! s:HiCursorWords__execute() if strlen(word) != 0 if strlen(g:HiCursorWords_hiGroupRegexp) != 0 \ && match(s:HiCursorWords__getHiName(linenum, colnum), g:HiCursorWords_hiGroupRegexp) == -1 - return + return endif let w:HiCursorWords__matchId = matchadd('WordUnderTheCursor', word, 0) endif @@ -116,4 +146,24 @@ function! s:HiCursorWords__startHilighting() augroup END endfunction +" Steven Lu: Add functionality to prevent the HCW styles being present in +" a vim window that is out of focus. For example, it confuses and interferes +" with vim-mark styles +function! s:HiCursorWords__stopHilighting() + if exists("w:HiCursorWords__matchId") + call matchdelete(w:HiCursorWords__matchId) + unlet w:HiCursorWords__matchId + endif +endfunction + +function! HiCursorWords_toggle() + if g:HiCursorWords_visible == 0 + highlight! link WordUnderTheCursor Underlined + let g:HiCursorWords_visible = 1 + else + highlight! link WordUnderTheCursor NONE + let g:HiCursorWords_visible = 0 + endif +endfunction + " vim: set et ft=vim sts=4 sw=4 ts=4 tw=78 : |