-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CursorLine priority issues when 'linking to Normal' #9019
Comments
With the cursor on the highlight, use |
Ok, the highlight group in question is But I can't seem to replicate pre 0.3.1 behaviour (or Vim 8.1 behaviour). Which is a full width If I set If I set If I manually set Closing this off seems hasty since we have a divergence with Vim 8.X and Neovim 0.3.0 and earlier without an obvious way for users to get back the old visual behaviour. |
That's
We might be able to special-case "linking to Normal" so that it works like |
No,
My opinion, that feels like a special case code spell. I don't like it. That being said, I have no idea how to get back the old behaviour whilst also keeping I think my ideal solution, as a Vim theme author, would be the suggestion of:
Currently Neovim treats that as a no-op when read in via Lastly, I think this issue should be re-opened until we have a solution or workaround. It highlights a legit regression compared to 0.3.0 and Vim 8.x. Thanks. |
I'm not sure why that would be a no-op. More likely it's just an ordering issue: if you do it after the colorscheme was executed, I would guess it works. Try putting it in an event handler:
|
Ok, in that context you suggestion is reasonable. It would be fine by me if it fixes this and has no deleterious side-effects.
Unfortunately, it does not work. I put your tip at the end of my Basically when I look at the value of |
With the autocmd in place, do the steps and then try |
Negative, no change. |
I am closing this issue, the obvious solution was staring me in the face from the start but I only just figured it out now. In my moonfly Vim theme, I simply needed to add:
For some reason I did not think to set a foreground color for Note, the vim-one theme has the same breakage as noted in the original post of this request. I suspect quite a few Vim themes are broken. However, the solution is simple as noted just above. I don't require any changes to Neovim. Thanks for your help, great project and excellent support. |
Solarized is also broken. Contrary to @bluz71, I believe this is a bug in neovim. It used to work in neovim, and still works in vim. And for everybody finding this via Google, the fix for solarized dark is
|
I'm experiencing this bug as well in nvim 0.3.1 with base16-vim. The cursorline sometimes has gaps in it: In vim 8.1 this doesn't happen; the cursorline background overrides on "Foo" correctly. I fixed it for now by adding |
I have the same. It didn't happen in nvim 0.3.0. In my case I see it for Any way to set CursorLine background's priority higher than other groups? |
To summarize this, this bug was due to my previous pull request to low the priority of CursorLine to fix other bugs. Unfortunately, since CursorLine previously had a higher priority in vim, so syntax author often linked a color back to Normal to "reset" the color, and thus they broke after that pull request. The simple workaround if you are not using bg color is to clear it using
Sorry, no. Vim's highlight priority is coded by thousands of lines of code rather than a number. |
This is only for people using a transparent background. I'm not sure most people do. I don't, for one. If this is going to be permanent, you should at least fix the syntaxes that are bundled with nvim, and that still link stuff to the Normal group. VimL syntax is one of them. Normal group could be replaced in these syntaxes by a Neutral group, that has the Normal foreground, but NONE as background, and have those groups that were previously linked to Normal, link to Neutral. |
That's unlikely to happen due to the complexity of itself and merging updates on vim script. |
Then I think that CursorLine background should have an higher priority over groups whose background color is the same as the Normal one, and that would include Normal group itself. |
The Neovim I worked around the NERDTree issue myself in my own moonfly theme, but I can't work around the IndentLine issue. There is a clear difference in behaviour now between Vim and Neovim with respect to justinmk said this earlier this thread:
I believe this issue should be re-opened and retitled. |
@bluz71 you could reopen it. The problem is about CursorLine priority, but not necessarily because of incompatibility with certain themes: also syntax can bind groups, in my case it is a syntax problem, not a theme one (I get the same with all themes). So just updating themes can't fix the problem. |
I forgot I could re-open :) |
Retitled: CursorLine priority issues when 'linking to Normal' |
Same problem here. |
b/c otherwise this conflicts with nvim patch that no longer favors `:highlight CursorLine`. refs neovim/neovim#9019 refs neovim/neovim#7383
I don't know if anyone has thought of this yet, but I did the following in my function! s:CustomizeColors()
if has('guirunning') || has('termguicolors')
let cursorline_gui=''
let cursorline_cterm='ctermfg=white'
else
let cursorline_gui='guifg=white'
let cursorline_cterm=''
endif
exec 'hi CursorLine ' . cursorline_gui . ' ' . cursorline_cterm
endfunction
augroup OnColorScheme
autocmd!
autocmd ColorScheme,BufEnter,BufWinEnter * call s:CustomizeColors()
augroup END As a note, I'm running on Windows Subsystem for Linux (WSL). I have not yet tested this on true Linux. NVIM v0.4.0-1597-g25fff17d1 |
@zfzackfrost works for me! thanks! |
Hi, any news on this issue ? |
I do not see this claimed anywhere and it will certainly not fix the problem. The only thing that is relevant is if |
@zfzackfrost Thanks for solution. However I'd like to have cursorline text to be syntax highlighted not just white. Could this script be modified in such way? |
It should not be white. The |
Neovim doesn't like when there is a link to a Normal group. neovim/neovim#9019
It's totally white for me as well and still doesn't work as expected. |
This might be because @zfzackfrost's solution doesn't correctly check for function! s:CustomizeColors()
if has('gui_running') || &termguicolors || exists('g:gonvim_running')
hi CursorLine ctermfg=white
else
hi CursorLine guifg=white
endif
endfunction
augroup OnColorScheme
autocmd!
autocmd ColorScheme,BufEnter,BufWinEnter * call s:CustomizeColors()
augroup END This workaround is also included in my fork of base16-vim. However, it is not EDIT: also negatively affects Diff* highlights as @justinmk states in this pull request |
This issue has caused me so much grief. The workaround listed by @a-vrma is the easiest but, as mentioned, has drawbacks. And it doesn't work for CursorColumn at all. AFAIK nothing similar can fix CursorColumn, which exhibits the same behavior even though no one seems to have mentioned it (see screenshot). The only thing I've found that fixes both CursorLine and CursorColumn is just about the ugliest hack you can imagine: after a colorscheme is loaded, scan every highlight group to find the ones where ctermbg/guibg have the same value as they do in Normal, or where they are set to Unfortunately, it's the only thing that makes CursorLine and CursorColumn actually work as they should - and as they do in vim8. |
I was trying to install nvim from fresh and stumbled upon similar issue. Most of popular color schemes I tried have highlight artifacts (incorrect background colors with enabled I asked #neovim:matrix.org for help and clason pointed me to this issue. So I wrote a hack similar to suggested by @captnjameskirk: it copies over If it could be useful for someone, here it is: To activate it, run this lua file after colorscheme gruvbox
runtime lua/hl_bg_fix.lua |
Thanks for the correction! I am using your version of my workaround in my config! |
Since I upgraded to Neovim 0.3.1 I notice NERDTree cursorline looks broken with my preferred Vim theme of moonfly.
Some Googling indicates others have the same experience as noted in this Reddit thread and following image.
Notice the
CursorLine
in the NERDTree window, it does not stretch across the full width of the window, it only highlights the section after thezsh
extension.I get the same result with my theme.
I think this relates to Neovim changes to CursorLine priority; especially if one only sets a
ctermbg
color without setting a foreground color. Reading through some of the Neovim CursorLine priority discussions it is mentioned that if one sets foreground and background then the priority system will not come it play. That is correct from my quick testing.However, in my case I do not want to set a foreground color for the
CursorLine
, I only set a low contrast background color whilst preserving the existing colors of the current line. Setting a CursorLine foreground color results in the loss of coloring for the current selected line (aka it looks ugly with my theme).How can I bypass Neovim CursorLine priority changes (for 0.3.1 and above) whilst only setting the background color?
Note, Vim 8.1 renders the NERDTree current line correctly via
CursorLine
if background is the only color set. Same went for Neovim 0.3.0 and earlier.Thanks.
The text was updated successfully, but these errors were encountered: