Skip to content

Commit 6f1d56d

Browse files
author
Bassam Data
committed
fix(selecta): fix highlights
1 parent 57dd360 commit 6f1d56d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lua/namu/selecta/selecta.lua

+16-9
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,24 @@ local function setup_highlights()
271271
local highlights = {
272272
SelectaPrefix = { link = "Special" },
273273
SelectaMatch = { link = "Identifier" }, -- or maybe DiagnosticFloatingOk
274-
-- BUG: only selectafilter cleared when changing colorscheme - drive me crazy
275-
SelectaFilter = { link = "Type" },
274+
-- SelectaFilter = { link = "Type" },
276275
SelectaCursor = { blend = 100, nocombine = true },
277276
SelectaPrompt = { link = "FloatTitle" },
278277
SelectaSelected = { link = "Statement" },
279278
SelectaFooter = { link = "Comment" },
280-
SelectaCurrentLine = { link = M.config.current_highlight.hl_group },
279+
-- SelectaCurrentLine = { link = M.config.current_highlight.hl_group },
281280
}
281+
282+
-- NOTE: for some wierd reason, this is the only way those 2 highlight groups works
283+
local current_hl_group = M.config.current_highlight.hl_group
284+
vim.cmd(string.format(
285+
[[
286+
highlight default link SelectaFilter Type
287+
highlight default link SelectaCurrentLine %s
288+
]],
289+
current_hl_group
290+
))
291+
282292
M.log("Setting up highlights...")
283293
for name, attrs in pairs(highlights) do
284294
vim.api.nvim_set_hl(0, name, attrs)
@@ -1729,18 +1739,15 @@ function M.setup(opts)
17291739
setup_highlights()
17301740
end)
17311741

1732-
if M.config.current_highlight.enabled then
1733-
vim.api.nvim_set_hl(0, "SelectaCurrentLine", {
1734-
link = M.config.current_highlight.hl_group,
1735-
})
1736-
end
17371742
-- Create autocmd for ColorScheme event
17381743
M.log("Creating ColorScheme autocmd")
17391744
vim.api.nvim_create_autocmd("ColorScheme", {
17401745
group = vim.api.nvim_create_augroup("SelectaHighlights", { clear = true }),
17411746
callback = function()
17421747
M.log("ColorScheme autocmd triggered")
1743-
setup_highlights()
1748+
vim.schedule(function()
1749+
setup_highlights()
1750+
end)
17441751
end,
17451752
})
17461753
end

0 commit comments

Comments
 (0)