chrisbra / Colorizer

color hex codes and color names
547 stars 30 forks source link

Create Color_* groups when s:HasGui() #73

Closed nickspoons closed 5 years ago

nickspoons commented 5 years ago

In gvim, and terminal vim with set termguicolors, certain scenarios trigger this error:

Colorizer: Some error occured here:  Colorize: ['^\s*\%(\%[Html]HiLink\s\+\w\+\s\+\w\+\)\|\(^\s*hi\%[ghlight]!\?\s\+\(clear\)\@!\S\+.*\)', function('<SNR>144_PreviewVimHighlight'), 'colorizer_vimhighlight', '&ft ==# "vim"', []]
Colorizer: Position: [0, 1, 1, 0]

This was triggered by running :ColorHighlight on a file containing the single line:

  highlight QuickFixLine NONE

The line triggering the error is autoload/Colorizer.vim#1734:

call matchadd(a:group, a:pattern, s:default_match_priority)

... which errors with E28, as the highlight group Color_QuickFixLine has not been created.

chrisbra commented 5 years ago

Thanks!

petobens commented 4 years ago

This PR broke the plugin functionality for me in neovim. With the following minimal init.vim:

let $DOTVIM = expand('$HOME/.config/nvim')

set runtimepath+=$DOTVIM/bundle/repos/github.com/chrisbra/Colorizer
" set runtimepath+=$DOTVIM/bundle/repos/github.com/chrisbra/Colorizer_53ada28
filetype plugin indent on
set termguicolors

" #98c379
" #61afef
" #e06c75

I don't get color highlight when using latest master (as in the first image). On the other hand everything works as expected when using a commit just before this one:

image

nickspoons commented 4 years ago

@petobens yes I can see that in neovim too.

However, if you add highlight QuickFixLine NONE to your example file and try to run it in neovim, the patched version at least succeeds with no errors - the previous commit errors out. So there's definitely something wrong here, but I don't think the PR should be rolled back. I don't know exactly what the problem is in neovim yet.

petobens commented 4 years ago

Mmm I actually do think it should either be rolled back or at least have a guard added checking for nvim until we figure out if there is indeed something wrong with neovim.

nickspoons commented 4 years ago

Well like I said, without this it errors out in neovim in some situations, which is worse than just displaying the wrong colours.