diff --git a/README.md b/README.md index 7391b9d..1b372fd 100644 --- a/README.md +++ b/README.md @@ -159,9 +159,9 @@ You can also use the source of the provider function. - `icon` is a string that will be added to the head of the provider result. It can also be a function that returns a string. -- `highlight` can be used in two ways. The first is to pass three elements: the first element is `fg`, the second is `bg`, and the third is `gui`. The second method is to pass a highlight group as a string (such as `IncSearch`) that galaxyline will link to. +- `highlight` is a string, function or table that can be used in two ways. The first is to pass three elements: the first element is `fg`, the second is `bg`, and the third is `gui`. The second method is to pass a highlight group as a string (such as `IncSearch`) that galaxyline will link to. -- `separator` is a string or table. notice that table type only work in mid section, It is not just a separator. Any statusline item can be +- `separator` is a string, function or table. notice that table type only work in mid section, It is not just a separator. Any statusline item can be defined here, like `%<`,`%{}`,`%n`, and so on. - `separator_highlight` same as highlight diff --git a/lua/galaxyline/colors.lua b/lua/galaxyline/colors.lua index dd173b8..27586e7 100644 --- a/lua/galaxyline/colors.lua +++ b/lua/galaxyline/colors.lua @@ -33,6 +33,12 @@ setmetatable(_switch,_switch_metatable) local function set_highlight(group, hi_info) local fg,bg,style = 'fg','bg','' + if type(hi_info) == 'function' then + hi_info = hi_info() + end + + if hi_info == nil then return end + if type(hi_info) == 'string' then api.nvim_command('highlight link ' .. group .. ' ' .. hi_info) return