" 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__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__mappings = 1): every " representative LHS below must be ABSENT. let s:disabled = [ \ ['wiki_prefix', 'ww', 'n'], \ ['wiki_prefix', 'ww', 'n'], \ ['links', '', 'n'], \ ['links', '+', 'n'], \ ['links', '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', '', 'n'], \ ['diary', '', 'n'], \ ['table_editing', 'gqq', 'n'], \ ['table_editing', '', 'n'], \ ['html_export', 'wh', 'n'], \ ['html_export', '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!')