Skip to content

Commit

Permalink
feat(toc): support todo status
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom authored and vhyrro committed Dec 26, 2023
1 parent d8a456b commit 4ac077b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lua/neorg/modules/core/qol/toc/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ module.public = {
else
prefix = nil
end
title = nil
elseif capture == "title" then
title = node
end
Expand Down Expand Up @@ -270,21 +271,16 @@ module.public = {

table.insert(start_lines, (prefix:start()))

local prefix_text =
module.required["core.integrations.treesitter"].get_node_text(prefix, norg_buffer)
local title_text =
vim.trim(module.required["core.integrations.treesitter"].get_node_text(title, norg_buffer))

if prefix_text:sub(1, 1) ~= "*" and prefix_text:match("^%W%W") then
prefix_text = table.concat({ prefix_text:sub(1, 1), " " })
end
local row_start_0b, col_start_0b, _, _ = prefix:range()
local _, _, row_end_0bin, col_end_0bex = title:range()
local heading_text = vim.api.nvim_buf_get_text(norg_buffer, row_start_0b, col_start_0b, row_end_0bin, col_end_0bex, {})

vim.api.nvim_buf_set_lines(
ui_buffer,
-1,
-1,
true,
{ table.concat({ prefix_text, title_text }) }
heading_text
)

prefix, title = nil, nil
Expand Down

0 comments on commit 4ac077b

Please sign in to comment.