Skip to content

Commit 31a0e8d

Browse files
committed
fix(feliniser): get highlight colours
1 parent 23be752 commit 31a0e8d

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

lua/arshamiser/feliniser/util.lua

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
local utils = require("heirline.utils")
2-
31
local M = {}
42

3+
---If highlight is a string, use it as highlight name and extract the
4+
-- properties from the highlight.
5+
-- Borrowed from the feline codebase.
6+
local function get_hl_properties(hlname)
7+
local hl = vim.api.nvim_get_hl_by_name(hlname, true)
8+
local styles = {}
9+
10+
for k, v in ipairs(hl) do
11+
if v == true then
12+
styles[#styles + 1] = k
13+
end
14+
end
15+
16+
return {
17+
name = hlname,
18+
fg = hl.foreground and string.format("#%06x", hl.foreground),
19+
bg = hl.background and string.format("#%06x", hl.background),
20+
style = next(styles) and table.concat(styles, ",") or "NONE",
21+
}
22+
end
23+
524
M.force_inactive = { --{{{
625
filetypes = {
726
"NvimTree",
@@ -34,12 +53,12 @@ M.colors = {--{{{
3453
light_bg = "#222930",
3554
light_bg2 = "#1d242b",
3655
mid_bg = "#2B3033",
37-
orange = utils.get_highlight("DiagnosticWarn").fg,
38-
cyan = utils.get_highlight("Special").fg,
39-
folder = utils.get_highlight("NvimTreeFolderIcon").fg,
40-
git_add = utils.get_highlight("DiffAdd").fg,
41-
git_del = utils.get_highlight("DiffDelete").bg,
42-
git_change = utils.get_highlight("DiffChange").fg,
56+
orange = get_hl_properties("DiagnosticWarn").fg,
57+
cyan = get_hl_properties("Special").fg,
58+
folder = get_hl_properties("NvimTreeFolderIcon").fg,
59+
git_add = get_hl_properties("DiffAdd").fg,
60+
git_del = get_hl_properties("DiffDelete").bg,
61+
git_change = get_hl_properties("DiffChange").fg,
4362
}
4463
--}}}
4564
-- stylua: ignore

0 commit comments

Comments
 (0)