feat(client): add per-subgroup Vim mapping opt-out globals
The plain-Vim ftplugin only exposed a whole-layer
g:nuwiki_no_default_mappings gate, so Vim users could not drop a single
keymap group the way Neovim users can via mappings.<group> = false. Add
g:nuwiki_no_{wiki_prefix,links,lists,headers,table_editing,diary,
html_export,text_objects}_mappings, each wrapping its group block, to
reach parity with lua/nuwiki/keymaps.lua. Cover them with a dedicated
opt-out harness and document them in the README and help file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
" development/tests/test-keymaps-vim-optout.vim — driven by
|
||||
" development/tests/test-keymaps-vim.sh.
|
||||
"
|
||||
" Per-subgroup mapping opt-out regression. The shell driver sets a subset
|
||||
" of `g:nuwiki_no_<group>_mappings = 1` globals *before* the ftplugin loads,
|
||||
" so this harness asserts that the disabled groups leave no buffer-local
|
||||
" mappings while the still-enabled groups keep theirs. Mirrors the Lua-side
|
||||
" subgroup toggles in lua/nuwiki/keymaps.lua.
|
||||
|
||||
let s:results = []
|
||||
let s:pass = 0
|
||||
let s:fail = 0
|
||||
let s:out = $NUWIKI_KEYMAP_RESULTS
|
||||
|
||||
function! s:record(ok, name, detail) abort
|
||||
let l:line = (a:ok ? 'PASS' : 'FAIL') . ' ' . a:name
|
||||
if a:detail !=# ''
|
||||
let l:line .= ' — ' . a:detail
|
||||
endif
|
||||
call add(s:results, l:line)
|
||||
if a:ok
|
||||
let s:pass += 1
|
||||
else
|
||||
let s:fail += 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:has_map(lhs, mode) abort
|
||||
let l:d = maparg(a:lhs, a:mode, 0, 1)
|
||||
return !empty(l:d) && get(l:d, 'buffer', 0)
|
||||
endfunction
|
||||
|
||||
" Groups the driver disabled (g:nuwiki_no_<group>_mappings = 1): every
|
||||
" representative LHS below must be ABSENT.
|
||||
let s:disabled = [
|
||||
\ ['wiki_prefix', '<Leader>ww', 'n'],
|
||||
\ ['wiki_prefix', '<Leader>w<Leader>w', 'n'],
|
||||
\ ['links', '<CR>', 'n'],
|
||||
\ ['links', '+', 'n'],
|
||||
\ ['links', '<Leader>wr', 'n'],
|
||||
\ ['headers', '=', 'n'],
|
||||
\ ['headers', ']]', 'n'],
|
||||
\ ['headers', ']u', 'n'],
|
||||
\ ['text_objects', 'ah', 'x'],
|
||||
\ ['text_objects', 'il', 'o'],
|
||||
\ ]
|
||||
for s:e in s:disabled
|
||||
let s:ok = !s:has_map(s:e[1], s:e[2])
|
||||
call s:record(s:ok ? 1 : 0, 'optout.' . s:e[0] . '.' . s:e[2] . '.' . s:e[1],
|
||||
\ s:ok ? '' : s:e[1] . ' (' . s:e[2] . ') still mapped despite opt-out')
|
||||
endfor
|
||||
|
||||
" Groups left enabled: every representative LHS must still be PRESENT.
|
||||
let s:enabled = [
|
||||
\ ['lists', 'gln', 'n'],
|
||||
\ ['lists', 'gnt', 'n'],
|
||||
\ ['lists', '<C-Space>', 'n'],
|
||||
\ ['diary', '<C-Down>', 'n'],
|
||||
\ ['table_editing', 'gqq', 'n'],
|
||||
\ ['table_editing', '<A-Left>', 'n'],
|
||||
\ ['html_export', '<Leader>wh', 'n'],
|
||||
\ ['html_export', '<Leader>wha', 'n'],
|
||||
\ ]
|
||||
for s:e in s:enabled
|
||||
let s:ok = s:has_map(s:e[1], s:e[2])
|
||||
call s:record(s:ok ? 1 : 0, 'kept.' . s:e[0] . '.' . s:e[2] . '.' . s:e[1],
|
||||
\ s:ok ? '' : s:e[1] . ' (' . s:e[2] . ') unexpectedly absent')
|
||||
endfor
|
||||
|
||||
call add(s:results, '')
|
||||
call add(s:results, printf('SUMMARY: %d passed, %d failed', s:pass, s:fail))
|
||||
call writefile(s:results, s:out)
|
||||
execute (s:fail == 0 ? 'qall!' : 'cquit!')
|
||||
Reference in New Issue
Block a user