Skip to content

Commit

Permalink
no need for all elements
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Apr 30, 2024
1 parent fd8e6e3 commit ac72d1f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lua/indentmini/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,24 @@ local function indentline(opt)
group = g,
buffer = bufnr,
callback = function()
local cur_hi = 'IndentLineCurrent'
local line, _ = unpack(api.nvim_win_get_cursor(0))
local level = math.floor(indent_fn(line) / vim.fn.shiftwidth())
local hls = api.nvim_get_hl(ns, {})
if level < 1 then
for k, _ in pairs(hls) do
api.nvim_set_hl(ns, k, { link = 'IndentLine' })
for k, v in pairs(hls) do
if v.link and v.link == cur_hi then
api.nvim_set_hl(ns, k, { link = 'IndentLine' })
break
end
end
return
end
local name = ('IndentLine%d'):format(level)
if hls[name] and hls[name].link and hls[name].link == 'IndentLineCurrent' then
if hls[name] and hls[name].link and hls[name].link == cur_hi then
return
end
api.nvim_set_hl(ns, name, { link = 'IndentLineCurrent' })
api.nvim_set_hl(ns, name, { link = cur_hi })
for k, _ in pairs(hls) do
if k ~= name then
api.nvim_set_hl(ns, k, { link = 'IndentLine' })
Expand Down

0 comments on commit ac72d1f

Please sign in to comment.