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:
2026-05-12 14:32:35 +00:00
parent 7c9e679169
commit cebc806ce3
7 changed files with 163 additions and 8 deletions
+19 -2
View File
@@ -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