Coc.nvim: Provide a way to let color theme plugin override the highlight of the "brackets" in floating window

Created on 8 Oct 2019  路  26Comments  路  Source: neoclide/coc.nvim

Tried a white but cannot find a way to override the highlight of brackets in the floating window:

Screen Shot 2019-10-08 at 11 21 55 AM

expectation:

want a way to let other plugins override it.

Most helpful comment

@crusoexia ah, I was hoping you found a fix. I ended up just setting "coc.preferences.enableFloatHighlight": false to get rid of all highlighting in the floating window.

All 26 comments

The highlight should be added by your other plugin, can't help.

@chemzqm which highlight group should I use? Tried a few in coc doc but none of them works.

build-in Normal group can affect it, but absolutely I don't want to change Normal highlight for it.

The highlight is added with background neovim with syntax plugins loaded only.

@crusoexia did you ever find a fix for this? I still have issues with this with pretty much every theme I try.

@ckipp01 no, I just choose the themes which let the issue not that obvious.

@crusoexia ah, I was hoping you found a fix. I ended up just setting "coc.preferences.enableFloatHighlight": false to get rid of all highlighting in the floating window.

I know this issue is closed now, but FWIW:

Per https://github.com/joshdick/onedark.vim/issues/197#issuecomment-574422967, this appears to be caused by coc using the background color from the Normal highlight group when drawing those characters in the floating window. A fix would be for coc to not to set/override a background color in this case.

@chemzqm or @fannheyward, do you think it's a possibility to make this change? I've seen this issue pop up in a few different issues, and I know I'd love to not have to have special code in my vim config just to account for this.

Had the same issue when using gruvbox colorscheme. Wouldn't work even if init.vim contained only coc.nvim configuration from readme + colorscheme gruvbox (or autocmd * VimEnter colorscheme gruvbox for that matter). It does work either with @ckipp01 solution (thank you so much for that!) or when setting the colorscheme manually after opening the editor (requires :syntax on too in order to produce desired effect). With the latter approach the highlights are preserved.

Even though this indeed looks like an issue, have you tried setting the highlight of the floating window background to match that of the char? On help you can find highlight group for the floating window, I had to use it myself to get it nicer for other reasons.

I don't exactly know how to do that. Played a bit with setting Pmenu and PmenuSel but it wouldn't change the color of those parts of the floating window.

Read docs/play with :h CocFloating@en, :h CocErrorFloat@en, etc.

Tried different combinations and it seems that this background colouring is independent of CocFloating, CocErrorFloat, ... :/ (Also I can see that CocFloating is linked to Pmenu by default.) Thanks for the suggestion though!

@jupblb I know it is, reason why I state that can be used to match the background with the background of this strange char you have no control over. Or you can simply patch the colorscheme you're using. I think coc.nvim should not provide special highlighting options for characters, this is an issue specific of a colorscheme, if you think a highlight group is broken with it, you can simply get the highlight group that gets broken, and override it for correction.

I think coc.nvim should not provide special highlighting options for characters, this is an issue specific of a colorscheme, if you think a highlight group is broken with it, you can simply get the highlight group that gets broken, and override it for correction.

Like I said above, this happens because coc uses the background color from the Normal highlight group when drawing those characters in the floating window.

Many colorschemes are likely to set an explicit background color for this highlight group, so I wouldn't classify this problem as being caused by specific colorschemes.

The only way for now is overwritten related highlight group in your vimrc.

@chemzqm Can I make an appeal for this to be looked at.

The issue as far as I see is that the '()' and maybe others do not use the same set of highlighting as the rest of the floating pane.

Instead they use the Normal highlight group. As such it is impossible to make the float all match unless the whole float matches the current main background colour.

I have no reall desire for there to be a specific group for these characters. Only that the same group is used for those characters as the surrounding ones

The rest of the float uses the CocFloating guibg colour. for some reason the () don't and instead use the Normal guibg colour

@ungrim97 we don't have an api to check the background color of specific highlight group or overwrite it for specific window/buffer, you can make background color of quote highlight to be transparent instead of guibg in your vimrc.

@chemzqm What @ungrim97 is asking is, why are the problem characters in the float not rendered with the same CocFloating highlight group inside the float, that most other characters inside floats seem to use with no problems?

@joshdick it should be using Normal for guibg, not like others using transparent background. You can overwrite that in your vimrc.

https://github.com/neoclide/coc.nvim/wiki/F.A.Q#highlight-of-background-seems-wrong-with-floating-window

Hi @chemzqm ,

Does that workaround only work for the onedark theme? I'm using the tender theme and can confirm this doesn't work on NeoVim 0.4.3.

checkout the highlight group yourself

I did but unfortunately I couldn't figure it out :disappointed: I'll raise an issue in the theme repo and see if I can get any help there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hackingcat picture hackingcat  路  3Comments

iago-lito picture iago-lito  路  3Comments

tom-james-watson picture tom-james-watson  路  3Comments

MacGuffinLife picture MacGuffinLife  路  4Comments

czepluch picture czepluch  路  3Comments