Closed linrongbin16 closed 8 months ago
BTW, colors must be one of the most important component to statusline plugin. People have all kinds of requirements to customize what they want.
I suggest provide colors as API library.
We could even provide an API, say render(text:string, fg_color:string?, fg_hl:string?, bg_color:string?, bg_hl:string?)
to allow people render a text with either/both fg and bg color, or retrieve color codes from vim's syntax highlighting group.
Then people could render text in their own content
function.
when people use (for example) color.yellow config/API, I believe this API is going to try to retrieve color from a syntax highlighting group (for example 'Visual')
It's actually the vim.g.terminal_color_11
variable: https://github.com/MunifTanjim/nougat.nvim/blob/700708b73c037e7800cbb27209247fdd1b6a122f/lua/nougat/color.lua#L216
There are actually multiple fallback mechanism.
nougat.color.<colorscheme>
module: https://github.com/MunifTanjim/nougat.nvim/blob/700708b73c037e7800cbb27209247fdd1b6a122f/lua/nougat/color.lua#L209require("nougat.color.<colorscheme>").get()
is missing a color, it looks for the vim.g.terminal_color_*
variable: https://github.com/MunifTanjim/nougat.nvim/blob/700708b73c037e7800cbb27209247fdd1b6a122f/lua/nougat/color.lua#L214change the API to color.yellow('Visual') to be more explicit
That's not actually explicit tho. Visual
can be yellow in a colorscheme and can be a completely different color in another colorscheme.
even people can customize the highlighting group name by themselves.
They already can. Create a nougat/color/<colorscheme>.lua
file in your config and put in the exact value you want for that theme. nougat.nvim
only suggests a few names: https://github.com/MunifTanjim/nougat.nvim/blob/700708b73c037e7800cbb27209247fdd1b6a122f/lua/nougat/color/README.md?plain=1#L25-L54 , but you can add additional colors too. For example: https://github.com/MunifTanjim/dotfiles/blob/a9cee0576ce0a853affc133a7812951ef3387493/private_dot_config/nvim/lua/nougat/color/gruvbox.lua. Here orange
is an extra color provided by my gruvbox
theme for nougat.nvim
.
If you use multiple colorschemes (e.g. gruvbox
, tokyonight
etc.), you can define the theme for nougat.nvim
either in your own config or in the colorscheme's repo (if they're willing to provide theme for nougat.nvim
).
I'd suggest to try the system for a bit with multiple colorschemes and switch between them to see if everything works as expected.
BTW, colors must be one of the most important component to statusline plugin. People have all kinds of requirements to customize what they want.
Yes, absolutely.
I suggest provide colors as API library.
We could even provide an API, say render(text:string, fg_color:string?, fg_hl:string?, bg_color:string?, bg_hl:string?) to allow people render a text with either/both fg and bg color, or retrieve color codes from vim's syntax highlighting group.
We do have a similar API tho.
local get_hl_name = require("nougat.color").get_hl_name
--
local hl_def = { bg = bg_color, fg = fg_color }
local fallback_hl_def = item.hl or ctx.hl
local text = "TEXT"
return core.highlight(get_hl_name(hl_def, fallback_hl_def)) .. text
And if you want to extract color from a highlight group, that is possible too.
local get_hl_def = require("nougat.color").get_hl_def
--
local bg = get_hl_def("Visual").bg
thanks!
Did you check the docs and existing issues?
Problem
This is not a bug, much more relate to system design.
But I think it's worth to discuss, when people use (for example)
color.yellow
config/API, I believe this API is going to try to retrieve color from a syntax highlighting group (for example 'Visual'), if failed it's going to useyellow
color as fallback.But people will not know what highlighting it's going to use.
We could either document it explicitly, or change the API to
color.yellow('Visual')
to be more explicit, and even people can customize the highlighting group name by themselves.Solution
Already in
Problem
section.Alternatives
No response
Additional Context
No response