-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add Highlight Groups For Even and Odd Lines #20092
Comments
I don't think this needs to be in core; (extmark) signs are much more efficient in Neovim, so a (Lua) plugin still sounds like the right option here. (@lewis6991 ?) |
A problem with implementing this as highlight groups is that this behavior is not wanted for every window/buffer, so if these highlight groups are added, one needs to override more highlight groups to change the background colors of a specific window. |
This appears to work: local ns = vim.api.nvim_create_namespace('evenoddlines')
vim.api.nvim_set_decoration_provider(ns, {
on_win = function()
end,
on_line = function(_, _, buf, row)
if row % 2 == 0 then
vim.api.nvim_buf_set_extmark(buf, ns, row, 0, {
end_row = row + 1,
hl_group = 'Visual',
hl_eol = true,
ephemeral = true
})
end
end
}) I did try with |
Looks like there already is a fine plugin, so I'm closing this as not needed in core. |
Thank you! |
This issue has been mentioned on Neovim Discourse. There might be relevant details there: https://neovim.discourse.group/t/init-lua-highlight-every-even-lines/3963/2 |
With |
Feature already in Vim?
No
Feature description
Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
I think it's nice for even and odd lines to have different highlights. It lets me quickly see which number in the line-number column any particular line corresponds to, regardless of how much whitespace is in front of it. It's a nice quality of life improvement when using relative numbers.
Currently, chrisbra's "DynamicSigns" plugin implements this functionality by adding signs to each line and giving them a different highlight whether they're even or odd. However, when a file has a relatively large number of lines, this causes an extreme slowdown and becomes almost unusable. Additionally, there are times when the signs to not update automatically.
Describe the solution you'd like
A builtin option of highlighting even and odd lines differently (LineEven and LineOdd hl-groups?). Here is an image using the DynamicSigns plugin:
Additional context
I have no idea about the feasibility of this, but I'm hoping it's a feature that is reasonable to add.
The highlighting doesn't even necessarily need to be tied to the line; as long as adjacent lines have different highlights, it makes it easier to see what line number each line corresponds to.
The text was updated successfully, but these errors were encountered: