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:
@@ -480,9 +480,25 @@ endfunction
|
||||
function! nuwiki#commands#colorize(color) abort
|
||||
call s:notify_deferred(':VimwikiColorize')
|
||||
endfunction
|
||||
" §13.1 Cluster C — link helpers.
|
||||
|
||||
function! nuwiki#commands#paste_link() abort
|
||||
call s:notify_deferred(':VimwikiPasteLink')
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{ 'uri': l:p['textDocument']['uri'], 'position': l:p['position'] }]
|
||||
call s:exec('nuwiki.link.pasteWikilink', l:args)
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#paste_url() abort
|
||||
call s:notify_deferred(':VimwikiPasteUrl')
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{ 'uri': l:p['textDocument']['uri'], 'position': l:p['position'] }]
|
||||
call s:exec('nuwiki.link.pasteUrl', l:args)
|
||||
endfunction
|
||||
|
||||
" `:VimwikiNormalizeLink` — wrap the word at cursor as `[[word]]`
|
||||
" without following. Pure-VimL.
|
||||
function! nuwiki#commands#normalize_link() abort
|
||||
if s:cursor_inside_wikilink()
|
||||
return
|
||||
endif
|
||||
call s:wrap_cword_as_wikilink()
|
||||
endfunction
|
||||
Reference in New Issue
Block a user