feat(toc): insert a fresh TOC at the cursor line
:NuwikiTOC inserted a new table of contents at the top of the file. It now inserts at the cursor line instead, so you can place the TOC where you want it (a blank line separates it from preceding text). An existing TOC is still refreshed in place, and auto_toc-on-save is unaffected. The Vim/Lua clients send the 0-based cursor line with nuwiki.toc.generate; the server threads it into toc_edit (clamped to the document) and falls back to the top of the file when absent. toc_rebuild_edit passes None. Tests: toc_edit_inserts_at_cursor_line + toc_edit_cursor_line_clamped_and_existing_replaced_in_place. 575 passed, clippy clean, keymap harnesses green. Doc updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -513,7 +513,11 @@ end
|
||||
|
||||
-- ===== Generation + workspace =====
|
||||
|
||||
M.toc_generate = function() exec('nuwiki.toc.generate', uri_args()) end
|
||||
M.toc_generate = function()
|
||||
-- Send the cursor line (0-based) so a fresh TOC is inserted there.
|
||||
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
|
||||
exec('nuwiki.toc.generate', { { uri = buf_uri(), line = line } })
|
||||
end
|
||||
-- `:VimwikiGenerateLinks [rel_path]` — optional path scopes the links to a
|
||||
-- subtree via the server's generateForPath; no arg = every page.
|
||||
M.links_generate = function(path)
|
||||
|
||||
Reference in New Issue
Block a user