-
-
Notifications
You must be signed in to change notification settings - Fork 636
fix(#2415): nvim 0.8 highlight overhaul support, limited to only show highest highlight precedence #2642
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
Conversation
e18b192 to
0da7f1b
Compare
nvim-tree is using `nvim_get_hl` which was introduced in nvim 0.9 to replace the unstable `get_hl_defs` in the following [commit](https://github.com/neovim/neovim/pull/22693/files). Unfortunately this raises an error in 0.8 nvim versions due to the function not existing. ``` Failed to run `config` for nvim-tree.lua ...are/nvim/lazy/nvim-tree.lua/lua/nvim-tree/appearance.lua:199: attempt to call field 'nvim_get_hl' (a nil value) stacktrace: - ~/.config/nvim/lua/confidenceman02/plugins/nvim-tree.lua:14 _in_ **config** - ~/.config/nvim/lua/confidenceman02/lazy.lua:14 ``` - Fall back to get_hl_defs when detecting 0.8 - Set the 'link' property to nil to emulate `link = false` in `builder.lua`
0da7f1b to
2f83247
Compare
lua/nvim-tree/renderer/builder.lua
Outdated
| local hl | ||
| if vim.fn.has "nvim-0.8" == 1 then | ||
| hl = vim.api.nvim__get_hl_defs(0)[group] or {} | ||
| if hl["link"] then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check feels a little overkill considering we default to a table. I'm too much of a lua noob to know for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine; safety first.
alex-courtis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for your work!
Let's invert those conditions, you test on 0.8, I test on 0.9 and we're ready to go.
lua/nvim-tree/renderer/builder.lua
Outdated
| local hl | ||
| if vim.fn.has "nvim-0.8" == 1 then | ||
| hl = vim.api.nvim__get_hl_defs(0)[group] or {} | ||
| if hl["link"] then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine; safety first.
lua/nvim-tree/appearance.lua
Outdated
| local hl_to = vim.api.nvim_get_hl(0, { name = to }) | ||
| local hl_from | ||
| local hl_to | ||
| if vim.fn.has "nvim-0.8" == 1 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we'll have to invert this condition: nvim-0.8 is true when using 0.9
I discovered this as nvim__get_hl_defs has been completely removed from 0.9. So much for non-breaking changes...
…only show highest highlight precedence
| if vim.fn.has "nvim-0.9" == 1 then | ||
| name_hl_group = self:create_combined_group(name_groups) | ||
| else | ||
| name_hl_group = name_groups[#name_groups] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no practical API to follow links all the way to the actual definitions, so we don't try.
nvim_get_hl_by_name and nvim__get_hl_defs can't follow the links nor give the right data for the setter. vim.fn.synIDtrans is a very tedious and time consuming method to get the real data and not worth the time.
|
Apologies for clobbering your changes; this is on the urgent side. Many thanks for raising and fixing this! |
…only show highest highlight precedence (nvim-tree#2642) * fix: Add support for get_hl_defs in nvim 0.8 nvim-tree is using `nvim_get_hl` which was introduced in nvim 0.9 to replace the unstable `get_hl_defs` in the following [commit](https://github.com/neovim/neovim/pull/22693/files). Unfortunately this raises an error in 0.8 nvim versions due to the function not existing. ``` Failed to run `config` for nvim-tree.lua ...are/nvim/lazy/nvim-tree.lua/lua/nvim-tree/appearance.lua:199: attempt to call field 'nvim_get_hl' (a nil value) stacktrace: - ~/.config/nvim/lua/confidenceman02/plugins/nvim-tree.lua:14 _in_ **config** - ~/.config/nvim/lua/confidenceman02/lazy.lua:14 ``` - Fall back to get_hl_defs when detecting 0.8 - Set the 'link' property to nil to emulate `link = false` in `builder.lua` * fix(nvim-tree#2415): nvim 0.8 highlight overhaul support, limited to only show highest highlight precedence --------- Co-authored-by: Jaime Terreu <[email protected]> Co-authored-by: Alexander Courtis <[email protected]>
Ah nice one! Yea sorry I was on an extended long, long weekend! Thanks again. |
nvim-tree is using
nvim_get_hlwhich was introduced in nvim 0.9 to replace the unstableget_hl_defsin the following commit.Unfortunately this raises an error in 0.8 nvim versions due to the function not existing.
link = falseinbuilder.lua