How can I get access to all the available colornames in neovim?

578 Views Asked by At

I want to get quick access to all colors available via color names (like "Red") in nvim.

Vim (without n) sources all colors from it's rtp ("/usr/share/vim/vim90/colors/lists/default.vim") as soon as defining a colorscheme. All colors are available then via let v:colornames.

What would be the nvim equivalent to vims let v:colornames?

But any way would do to get a list of the available color names. Optimally to use them in lua.


Edit:

Another way to state the question to serve the usecase: Is there a better way to check if a colorname like "Red" is available before passing it as a highlight value in nvim_set_hl.

Currently I would do it like this:

local is_col, _ = pcall(vim.api.nvim_set_hl, 0, "Normal", { fg = "Red" })
if is_col then print(is_col) end -- <-- true

local is_col, _ = pcall(vim.api.nvim_set_hl, 0, "Normal", { fg = "Redish" })
print(is_col) -- <-- false
0

There are 0 best solutions below