Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HawtKeysAll highlights bug #52

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading