Skip to content

Commit

Permalink
fix: HawtKeysAll highlights bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Dec 24, 2023
1 parent f0657dd commit ae1efb1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lua/hawtkeys/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ M.show_all = function()
local filename = data.from_file:gsub(vim.env.HOME, "~")
local line = pattern:format(data.lhs, data.mode, filename)

local offset_mode = #data.lhs + 2
local offset_file = offset_mode + #data.mode + 2

local l2 = data.rhs
if l2 == nil or l2 == "" then
l2 = "<unknown>"
Expand All @@ -276,6 +279,11 @@ M.show_all = function()
virt_lines = { { { l2, "Function" } } },
})

-- mapping rhs as extmark so the cursor skips over it
vim.api.nvim_buf_set_extmark(ResultBuf, Namespace, i - 1, 0, {
virt_lines = { { { l2, "Function" } } },
})

vim.api.nvim_buf_set_lines(
ResultBuf,
i == 1 and 0 or -1,
Expand All @@ -284,7 +292,18 @@ M.show_all = function()
{ line }
)
-- highlight the filename
vim.api.nvim_buf_add_highlight(ResultBuf, -1, "Comment", i - 1, 0, -1)
vim.api.nvim_buf_add_highlight(
ResultBuf,
-1,
"Comment",
i - 1,
offset_file,
-1
)
-- mapping rhs as extmark so the cursor skips over it
vim.api.nvim_buf_set_extmark(ResultBuf, Namespace, i - 1, 0, {
virt_lines = { { { l2, "Function" } } },
})
end
end

Expand Down

0 comments on commit ae1efb1

Please sign in to comment.