feat(13.1-C): link helpers — pasteWikilink, pasteUrl, normalize
Closing out §13.1's smallest cluster. Three commands move from "not yet implemented" stubs to real behaviour: - `nuwiki.link.pasteWikilink` (server, executeCommand) — derives the current page name from the source URI + wiki root, returns a `WorkspaceEdit` inserting `[[<page>]]` at the requested cursor position. - `nuwiki.link.pasteUrl` (server) — same lookup, but the inserted text is the page's relative HTML output URL (`<page>.html`, including subdir segments) so the snippet survives when the export root moves. - `nuwiki.link.normalize` (client) — wraps the word at cursor as `[[word]]` without following. Reuses the `wrap_cword_as_wikilink` helper that already powers the `<CR>` two-step. Pure-VimL on the Vim path; pure-Lua on the Neovim path. No LSP round-trip. Keymaps: - `+` (normal + visual) now actually calls `normalize_link` on both editor paths instead of stubbing with a "deferred" notification. Tests: - 5 new Rust unit tests in `cluster_c_link_helpers.rs` covering command-list presence + the page-name derivation for root and subdirectory pages + the URL / wikilink shape strings. - Neovim keymap harness gains a `links.normalize_via_+` case (20 passing now, up from 19). Vim harness inherits the same command-presence check via its existing smoke tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+19
-2
@@ -444,7 +444,24 @@ M.table_insert = _not_yet(':VimwikiTable')
|
||||
M.table_move_column_left = _not_yet(':VimwikiTableMoveColumnLeft')
|
||||
M.table_move_column_right = _not_yet(':VimwikiTableMoveColumnRight')
|
||||
M.colorize = _not_yet(':VimwikiColorize')
|
||||
M.paste_link = _not_yet(':VimwikiPasteLink')
|
||||
M.paste_url = _not_yet(':VimwikiPasteUrl')
|
||||
|
||||
-- §13.1 Cluster C — link helpers.
|
||||
|
||||
function M.paste_link()
|
||||
exec('nuwiki.link.pasteWikilink', pos_args())
|
||||
end
|
||||
|
||||
function M.paste_url()
|
||||
exec('nuwiki.link.pasteUrl', pos_args())
|
||||
end
|
||||
|
||||
--- Vimwiki `:VimwikiNormalizeLink` — wrap the word at cursor as
|
||||
--- `[[word]]` without following. The `<CR>` two-step does the same
|
||||
--- thing under the hood; expose it as a standalone command + keymap
|
||||
--- for users who want to bind it to `+` per vimwiki defaults.
|
||||
function M.normalize_link()
|
||||
if cursor_inside_wikilink() then return end
|
||||
wrap_cword_as_wikilink()
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -184,8 +184,8 @@ function M.attach(bufnr, mappings)
|
||||
map('n', '<BS>', '<C-o>', { desc = 'nuwiki: go back', remap = true }, bufnr)
|
||||
map('n', '<Tab>', link.next, { desc = 'nuwiki: next wikilink' }, bufnr)
|
||||
map('n', '<S-Tab>', link.prev, { desc = 'nuwiki: prev wikilink' }, bufnr)
|
||||
map('n', '+', deferred(':VimwikiNormalizeLink'), { desc = 'nuwiki: normalize link (deferred)' }, bufnr)
|
||||
map('x', '+', deferred(':VimwikiNormalizeLink'), { desc = 'nuwiki: normalize link (deferred)' }, bufnr)
|
||||
map('n', '+', cmd.normalize_link, { desc = 'nuwiki: wrap word as wikilink' }, bufnr)
|
||||
map('x', '+', cmd.normalize_link, { desc = 'nuwiki: wrap word as wikilink' }, bufnr)
|
||||
map('n', '<Leader>wn', cmd.wiki_goto_page, { desc = 'nuwiki: goto page' }, bufnr)
|
||||
map('n', '<Leader>wd', cmd.delete_file, { desc = 'nuwiki: delete page' }, bufnr)
|
||||
map('n', '<Leader>wr', cmd.rename_file, { desc = 'nuwiki: rename page' }, bufnr)
|
||||
|
||||
Reference in New Issue
Block a user