sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.96k stars 166 forks source link

Orange Indentline highlight in coc-explorer #172

Closed leoatchina closed 1 year ago

leoatchina commented 1 year ago

I have done the following steps before reporting this issue:

Operating system/version

windows but ssh to linux

Terminal emulator/version

All terminal I have used , include tabby , windows terminal, wezterm , mobaxterm

$TERM environment variable

not need

Tmux version

not need

Feature matrix

Open Coc-explore in vim/neovim, either sidebar or float

Minimal vimrc that can reproduce this bug.

not need , It happend when use colorscheme sonokai, edge, gruvbox-material, everest

image

After I changed colorscheme to nightfox image

Steps to reproduce this bug using minimal vimrc

  1. install coc.nvim, and coc-explore, and opend coc-explorer
  2. In nvim 0.9, I do :inspect on the orange block
  3. got this image
  4. do verbose highlight CocExploreIndent 4 got this image

Expected behavior

not orange indentline

Actual behavior

orange indentline

antoineco commented 1 year ago

Thanks for the very detailed issue report! 🙌 Let me look into this.

antoineco commented 1 year ago

What does :verbose hi Conceal return?

leoatchina commented 1 year ago
Conceal        xxx ctermfg=239 ctermbg=202 guifg=#5a524c guibg=#ff5f00                                                                                                                                                                                                      
        最近修改于 ~/.leovim.d/plug/coc.nvim/indentLine/after/plugin/indentLine.vim line 88       
antoineco commented 1 year ago

There you go, Conceal was overwritten by indentLine.vim (#5a524c #ff5f00)

antoineco commented 1 year ago

Are you using a theme in your terminal which might be overriding grey colors, such as base16-shell?

leoatchina commented 1 year ago

Actually , after I deleted line 1493 in gruvbox-mateial.vim, this bug disappeared I donot installed base16-shell, but have tested lots of colorschemes, and I am sure this bug is only related with edge, sonokai, gruvbox-material, everest image

antoineco commented 1 year ago

indentline is forcing the background color to your terminal's color, so if you rewrote these to orange (like base16-shell does), they will show as orange in Vim too:

https://github.com/Yggdroot/indentLine/blob/d15d63bf9c4a74a02470d4bc8ecce53df13e3a75/after/plugin/indentLine.vim#L47-L53

What happens if you reload the colorscheme, for example with :colorscheme desert | colorscheme gruvbox-material?

leoatchina commented 1 year ago

sublime image

desert image

edge image

everforest image

sonokai image

gruvbox-material after I delete line 1493 image

antoineco commented 1 year ago

The reason why you don't see it in other colorschemes is because gruvbox-material (and all sainnhe's themes) doesn't force a background color, so indentline happily enforces its own color on top. This is a bad default from the plugin in my opinion.

https://github.com/sainnhe/gruvbox-material/blob/53592367dc073cd5b5cbe5b6fae56ad82d0c29f6/colors/gruvbox-material.vim#L90

Try this:

" Apply custom highlights on colorscheme change.
" Must be declared before executing ':colorscheme'.
augroup custom_highlights_gruvboxmaterial
  autocmd!
  " reset indentline default
  autocmd ColorScheme gruvbox-material 
  \ hi! Conceal ctermbg=NONE guibg=NONE
augroup END

colorscheme gruvbox-material

or in Lua

-- Apply custom highlights on colorscheme change.
-- Must be declared before executing ':colorscheme'.
grpid = vim.api.nvim_create_augroup('custom_highlights_gruvboxmaterial', {})
vim.api.nvim_create_autocmd('ColorScheme', {
  group = grpid,
  pattern = 'gruvbox-material',
  command = -- reset indentline default
            'hi! Conceal ctermbg=NONE guibg=NONE'
})

vim.cmd'colorscheme gruvbox-material'
leoatchina commented 1 year ago

Should be like this

augroup Fix_CocExploererIndentline
    autocmd!
    autocmd ColorScheme gruvbox-material hi! CocExplorerIndentLine ctermbg=NONE guibg=NONE
    autocmd ColorScheme edge             hi! CocExplorerIndentLine ctermbg=NONE guibg=NONE
    autocmd ColorScheme sonokai          hi! CocExplorerIndentLine ctermbg=NONE guibg=NONE
    autocmd ColorScheme everforest       hi! CocExplorerIndentLine ctermbg=NONE guibg=NONE
augroup END
leoatchina commented 1 year ago

Also fixed vimLineComment bug

augroup Fix_CocColorScheme
    autocmd!
    autocmd ColorScheme edge,sonokai,everforest,gruvbox-material autocmd BufWinEnter * hi! vimLineComment ctermbg=NONE guibg=NONE
    autocmd ColorScheme edge,sonokai,everforest,gruvbox-material hi! CocExplorerIndentLine ctermbg=NONE guibg=NONE
augroup END
antoineco commented 1 year ago

It would be better to fix the Conceal highlight group directly like I suggested.

The root cause of your issues is that indenline hijacks the Conceal group (which is a Vim core highlight group and shouldn't be overridden by plugins). If you fix Conceal, you fix all issues at once.

leoatchina commented 1 year ago

Actually I have tried to fix Conceal group at first bu not work, so I tried CocExplorerIndentLine and it worked