feat(parity): close the entire P3 Mappings section

Both remaining mapping gaps (client-side, both clients):

- Visual <CR>: upstream binds it to NormalizeLinkVisualCR (== visual `+`).
  Added `x <CR>` -> normalize_link(true) (wrap the selection as a wikilink)
  in both clients.

- Insert <S-CR>: upstream's multiline-list-item continuation (VimwikiReturn
  2 2 -> kbd_cr with no new marker). New smart_shift_return (both clients,
  <expr> insert mapping): on a list item returns <CR> + spaces aligning under
  the item text (marker width + 1, +4 for a `[ ] ` checkbox), no marker; off a
  list item, a plain <CR>. Mirrors smart_return's auto-indent handling.

Tests: map.visual_cr_wraps_selection + map.insert_shift_cr_multiline
(test-keymaps.lua, the latter exercising the handler directly since <S-CR>
doesn't round-trip headless feedkeys), and map.visual_cr_wraps_selection +
cr.shift_cr_multiline{,_checkbox} (test-keymaps-vim.vim). Docs (README +
doc/nuwiki.txt) and the gap doc updated. Neovim 305, Vim 299/18/21 pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 11:04:56 +00:00
parent 305324c6e9
commit 724712121d
9 changed files with 146 additions and 7 deletions
+23
View File
@@ -1310,6 +1310,29 @@ function! nuwiki#commands#smart_return() abort
return "\<CR>"
endfunction
" Insert-mode `<S-CR>`: continue the current list item on a new line WITHOUT a
" new marker, indented to align under the item's text — vimwiki's "multiline
" list item" (`VimwikiReturn 2 2`). Off a list item it's a plain `<CR>`.
function! nuwiki#commands#smart_shift_return() abort
let l:line = getline('.')
let l:m = matchlist(l:line, '^\(\s*\)\([-*#]\)\s\(.*\)$')
if empty(l:m)
let l:m2 = matchlist(l:line, '^\(\s*\)\(\d\+\)\([.)]\)\s\(.*\)$')
if !empty(l:m2)
let l:m = [l:line, l:m2[1], l:m2[2] . l:m2[3], l:m2[4]]
endif
endif
if empty(l:m)
return "\<CR>"
endif
let l:indent = l:m[1]
let l:marker = l:m[2]
let l:has_cb = l:m[3] =~# '^\[[ xXoO.\-]\]'
let l:pad = len(l:marker) + 1 + (l:has_cb ? 4 : 0)
let l:auto = &autoindent || &smartindent || &cindent || !empty(&indentexpr)
return "\<CR>" . (l:auto ? '' : l:indent) . repeat(' ', l:pad)
endfunction
" :VimwikiReturn / :NuwikiReturn — the command form of the smart `<CR>`
" continuation (upstream's mapping-driven `VimwikiReturn`). Enters insert at
" end of line and triggers the buffer-local `<CR>` mapping (smart_return),