I noticed that git icons are no longer being coloured correctly for
NvimTreeGitStaged
NvimTreeGitMerge
NvimTreeGitRenamed
NvimTreeGitNew
Looking at :verbose hi NvimTreeGitMerge` for example I get
:verbose hi NvimTreeGitMerge
NvimTreeGitMerge xxx guifg=13736550
Last set from ~/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua/plugin/tree.vim line 16
The guifg color is not actually a valid hex colour. I'm not sure how this is being derived or if some underlying API changed etc.
I just wanted to track this, so it's known that this happens. I'll try and dig in and maybe raise a PR if I get some time to debug and fix it.
nothing changed on my end. Maybe orange = vim.g.terminal_color_11 or get_color_from_hl('Number', 'Orange') is getting your terminal_color_11 from your colorscheme wrongly ? Mine is perfectly fine. Which colorscheme do you use ?
@kyazdani42 I use rakr/vim-one I've used it for years now and it never had an issue with nvim tree before I only just noticed this but think it's been this way on my end for a little while a couple of months maybe not sure tbh been meaning to actually look into it
Ah I see the issue just looked at the definition of get_color_from_hl. It uses nvim_get_hl_by_id and co. these functions don't actually return hex values they return rgb values so they can't be used directly in gui{fg/bg} for highlights. In nvim-bufferline the plugin I made I have to do a lot of colour stuff and I hit this before. There is no official api that returns valid hex colours so I use
function M.get_hex(hl_name, part, fallback)
if not fallback then fallback = "none" end
local id = vim.fn.hlID(hl_name)
local color = vim.fn.synIDattr(id, part)
-- if we can't find the color we default to none
if not color or color == "" then return fallback else return color end
end
local normal_bg = M.get_hex("Normal", "bg")
I don't think my color scheme sets the terminal colours that are being used there
indeed vim-one doesn't define these colors. And i just made a little debugging indeed nvim_get_hl_by_id returns a weird rgb value...
I'll push a fix
fixed in 7e3534c
Thanks @kyazdani42 that works great 馃憤馃徔
ure code mate :)
Hello. I started having issues loading nvim-tree after commit 7e3534c2bc31b203b6ff6a53f7ccc94c19ec813b. I did some debugging and it looks like you forget to check if foreground was an empty string.
function M.get_hex(hl_name, part, fallback) if not fallback then fallback = "none" end local id = vim.fn.hlID(hl_name) local color = vim.fn.synIDattr(id, part) -- if we can't find the color we default to none if not color or color == "" then return fallback else return color end end local normal_bg = M.get_hex("Normal", "bg")
Turns out @akinsho 's code for checking if color is an empty string is required!
All in all it's a simple fix:
local function get_color_from_hl(hl_name, fallback)
local id = vim.api.nvim_get_hl_id_by_name(hl_name)
if not id then return fallback end
local foreground = vim.fn.synIDattr(id, "fg")
if not foreground or foreground == "" then return fallback end
return foreground
end
sorry, didn't know that :) i'm pushing the fix you mentionned, thanks for noticing !