itchyny / vim-cursorword

Underlines the word under the cursor
http://www.vim.org/scripts/script.php?script_id=5100
MIT License
611 stars 36 forks source link

Allow to customize highlight groups #16

Closed lervag closed 6 years ago

lervag commented 6 years ago

It seems that the cursorword#highlight function overrides my attempts at customizing the CursorWord[01] highlight groups. Would it be possible to make a minor change that allows me to customize these groups?

lervag commented 6 years ago

At least, it seems trivial to allow to customize the CursorWord0 group. I see that there is some minor magic for the CursorWord1 group which might complicate things.

itchyny commented 6 years ago

Try let g:cursorword_highlight = 0, the plugin stops setting the highlight colors.

lervag commented 6 years ago

That seems close to what I want. And I guess I can achieve my desired customization with something like this:

let g:cursorword_highlight = 0

augroup cursorword
  autocmd!
  autocmd VimEnter,ColorScheme * call MyHighlight()
augroup END

function! MyHighlight() abort
  highlight CursorWord0 cterm=bold gui=bold

  redir => out
    silent! highlight CursorLine
  redir END
  execute 'highlight CursorWord1 cterm=underline gui=underline'
    \ matchstr(out, 'ctermbg=#\?\w\+')
    \ matchstr(out, 'guibg=#\?\w\+')
endfunction

Thanks