Skip to content

Commit

Permalink
fix(introspector): various bugs related to extmark updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Mar 28, 2024
1 parent 5f67407 commit e8c9193
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lua/neorg/modules/core/todo-introspector/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ function module.public.attach_introspector(buffer)
)

vim.api.nvim_buf_attach(buffer, false, {
on_lines = vim.schedule_wrap(function(_, buf, _, first)
on_lines = function(_, buf, _, first)
---@type TSNode?
local node = module.required["core.integrations.treesitter"].get_first_node_on_line(buf, first)

vim.api.nvim_buf_clear_namespace(buffer, module.private.namespace, first + 1, first + 1)

local parent = node

while parent do
Expand All @@ -76,7 +78,7 @@ function module.public.attach_introspector(buffer)

parent = parent:parent()
end
end),
end,

on_detach = function()
vim.api.nvim_buf_clear_namespace(buffer, module.private.namespace, 0, -1)
Expand Down Expand Up @@ -133,17 +135,15 @@ function module.public.perform_introspection(buffer, node)

local line, col = node:start()

local unique_id = assert(tonumber(tostring(buffer) .. tostring(node:symbol()) .. tostring(line)))
vim.api.nvim_buf_clear_namespace(buffer, module.private.namespace, line, line + 1)

if total == 0 then
vim.api.nvim_buf_del_extmark(buffer, module.private.namespace, unique_id)
return
end

-- TODO: Make configurable, make colours customizable, don't display [x/total]
-- as the total also includes things like uncertain tasks.
vim.api.nvim_buf_set_extmark(buffer, module.private.namespace, line, col, {
id = unique_id,
virt_text = { { string.format("[%d/%d]", counts.done, total), "Normal" } },
})
end
Expand Down

0 comments on commit e8c9193

Please sign in to comment.