parity(2): insert-mode list bindings (<C-D>/<C-T>/<C-L><C-?>)
Match upstream vimwiki's insert-mode list editing: <C-D> list_change_level(-1) dedent current item <C-T> list_change_level(+1) indent current item <C-L><C-J> list_cycle_symbol(+1) cycle marker forward <C-L><C-K> list_cycle_symbol(-1) cycle marker backward <C-L><C-M> list_toggle_or_add_chk toggle if has checkbox, else add `[ ]` Cycle order matches vimwiki's canonical run: - → * → # → 1. → 1) → a) → A) → i) → I) → (wrap) Both Lua and VimL paths wired. Lua callbacks fire directly (no `<C-o>` dance) since list_change_level / changeSymbol mutate the buffer via the LSP applyEdit pipeline, which works cleanly in insert mode. VimL keeps the `<C-o>:call …<CR>` idiom since that's the standard there. Harness adds 5 cases covering the new insert-mode bindings plus one direct LSP roundtrip for changeSymbol — surfaced a long-standing stale-binary footgun in test-keymaps.sh (rebuilt only when bin was missing; now rebuilds every run since incremental cargo is fast). Harness also captures server log_messages and dumps them on failure so future swallowed-error bugs (Err → log + Ok(None)) are visible. Gates: 421 Rust / 25 Neovim / 12 Vim. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -551,6 +551,47 @@ function! nuwiki#commands#list_change_lvl(...) abort
|
||||
let l:delta = (l:dir ==# 'increase' || l:dir ==# 'indent') ? 1 : -1
|
||||
call nuwiki#commands#list_change_level(l:delta, 0)
|
||||
endfunction
|
||||
|
||||
" Cycle the list marker through vimwiki's canonical order.
|
||||
let s:symbol_order = ['-', '*', '#', '1.', '1)', 'a)', 'A)', 'i)', 'I)']
|
||||
|
||||
function! s:detect_symbol() abort
|
||||
let l:line = getline('.')
|
||||
let l:m = matchlist(l:line, '^\s*\([-*#]\)\s')
|
||||
if !empty(l:m) | return l:m[1] | endif
|
||||
let l:m = matchlist(l:line, '^\s*\d\+\([.)]\)\s')
|
||||
if !empty(l:m) | return '1' . l:m[1] | endif
|
||||
if l:line =~# '^\s*[ivxlcdm]\+)\s' | return 'i)' | endif
|
||||
if l:line =~# '^\s*[IVXLCDM]\+)\s' | return 'I)' | endif
|
||||
if l:line =~# '^\s*[a-z]\+)\s' | return 'a)' | endif
|
||||
if l:line =~# '^\s*[A-Z]\+)\s' | return 'A)' | endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#list_cycle_symbol(direction) abort
|
||||
let l:cur = s:detect_symbol()
|
||||
if l:cur ==# '' | return | endif
|
||||
let l:idx = index(s:symbol_order, l:cur)
|
||||
if l:idx < 0 | return | endif
|
||||
let l:n = (l:idx + a:direction) % len(s:symbol_order)
|
||||
if l:n < 0 | let l:n += len(s:symbol_order) | endif
|
||||
call nuwiki#commands#list_change_symbol(s:symbol_order[l:n], 0)
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#list_toggle_or_add_checkbox() abort
|
||||
let l:line = getline('.')
|
||||
if l:line =~# '^\s*[-*#]\s\+\[[ xXoO.\-]\]' || l:line =~# '^\s*\w\+[.)]\s\+\[[ xXoO.\-]\]'
|
||||
call nuwiki#commands#toggle_list_item()
|
||||
return
|
||||
endif
|
||||
let l:end = matchend(l:line, '^\s*[-*#] ')
|
||||
if l:end < 0
|
||||
let l:end = matchend(l:line, '^\s*\w\+[.)] ')
|
||||
endif
|
||||
if l:end < 0 | return | endif
|
||||
let l:new = strpart(l:line, 0, l:end) . '[ ] ' . strpart(l:line, l:end)
|
||||
call setline('.', l:new)
|
||||
endfunction
|
||||
" §13.1 Cluster B — table rewriters.
|
||||
|
||||
function! nuwiki#commands#table_insert(...) abort
|
||||
|
||||
Reference in New Issue
Block a user