Skip to content

Commit 2e4f0f9

Browse files
author
Astro
authored
Merge pull request #16 from Gelio/fix-hl_ns-breaking-change
Use global namespace to define highlights (fixes plugin after recent Neovim `hl_ns` breaking change)
2 parents d848936 + 5e35a9f commit 2e4f0f9

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

lua/dim.lua

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function util.darken(hex, amount, bg)
3838
return util.blend(hex, bg or "#000000", math.abs(amount))
3939
end
4040

41-
function util.highlight_word(ns, line, from, to)
41+
function util.highlight_word(line, from, to)
4242
-- null ls
4343
if from == to and to == 0 then
4444
from = 0
@@ -54,12 +54,9 @@ function util.highlight_word(ns, line, from, to)
5454
if #color ~= 7 then
5555
color = "#ffffff"
5656
end
57-
vim.api.nvim_set_hl(
58-
dim.ns,
59-
string.format("%sDimmed", final),
60-
{ fg = util.darken(color, 0.75), undercurl = false, underline = false }
61-
)
62-
vim.api.nvim_buf_add_highlight(0, ns, string.format("%sDimmed", final), line, from, to)
57+
local hl_group = string.format("%sDimmed", final)
58+
vim.api.nvim_set_hl(0, hl_group, { fg = util.darken(color, 0.75), undercurl = false, underline = false })
59+
vim.api.nvim_buf_add_highlight(0, dim.ns, hl_group, line, from, to)
6360
if dim.opts.disable_lsp_decorations then
6461
for _, lsp_ns in pairs(vim.diagnostic.get_namespaces()) do
6562
local namespaces_to_clear = { "underline_ns", "virt_text_ns", "sign_group" }
@@ -132,7 +129,7 @@ dim.hig_unused = function()
132129
vim.api.nvim_buf_clear_namespace(0, dim.ns, 0, -1)
133130
for _, lsp_datum in ipairs(lsp_data) do
134131
if diagnostic_util.is_unused_symbol_diagnostic(lsp_datum) then
135-
util.highlight_word(dim.ns, lsp_datum.lnum, lsp_datum.col, lsp_datum.end_col)
132+
util.highlight_word(lsp_datum.lnum, lsp_datum.col, lsp_datum.end_col)
136133
end
137134
end
138135
end
@@ -154,8 +151,6 @@ dim.setup = function(tbl)
154151
autocmd DiagnosticChanged * lua require("dim").hig_unused()
155152
augroup END
156153
]])
157-
158-
vim.api.nvim__set_hl_ns(dim.ns)
159154
end
160155

161156
return dim

0 commit comments

Comments
 (0)