Skip to content

Commit

Permalink
Merge pull request #129 from Reptarsrage/main
Browse files Browse the repository at this point in the history
Allowing colors to be functions
  • Loading branch information
glepnir authored Apr 4, 2021
2 parents 180177f + 9df9e8d commit b4ca8f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lua/galaxyline/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4ca8f1

Please sign in to comment.