feat(client): add per-subgroup Vim mapping opt-out globals
CI / cargo fmt --check (push) Successful in 40s
CI / cargo clippy (push) Failing after 38s
CI / cargo test (push) Successful in 38s
CI / editor keymaps (push) Successful in 1m30s

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:
2026-05-30 23:40:29 -03:00
parent 3a33d53c22
commit e9243f743e
5 changed files with 269 additions and 103 deletions
+116 -97
View File
@@ -171,90 +171,103 @@ if !has('nvim')
" ===== Default key mappings (parity with upstream vimwiki) =====
"
" Users can opt out by setting `g:nuwiki_no_default_mappings = 1`
" (whole layer) or by adding their own competing buffer-local maps.
" Users can opt out of the whole layer with `g:nuwiki_no_default_mappings = 1`,
" or flip individual subgroups off via `g:nuwiki_no_<group>_mappings = 1`
" (group ∈ wiki_prefix, links, lists, headers, table_editing, diary,
" html_export, text_objects). These mirror the Lua-side `mappings.<group>`
" toggles in lua/nuwiki/keymaps.lua.
if !get(g:, 'nuwiki_no_default_mappings', 0)
" Wiki prefix
nnoremap <silent><buffer> <Leader>ww :call nuwiki#commands#wiki_index(0)<CR>
nnoremap <silent><buffer> <Leader>wt :call nuwiki#commands#wiki_tab_index(0)<CR>
nnoremap <silent><buffer> <Leader>ws :call nuwiki#commands#wiki_ui_select()<CR>
nnoremap <silent><buffer> <Leader>wi :call nuwiki#commands#diary_index()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>w :call nuwiki#commands#diary_today()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>y :call nuwiki#commands#diary_yesterday()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>t :call nuwiki#commands#diary_tomorrow()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>m :call nuwiki#commands#diary_tomorrow()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>i :call nuwiki#commands#diary_generate_index()<CR>
if !get(g:, 'nuwiki_no_wiki_prefix_mappings', 0)
nnoremap <silent><buffer> <Leader>ww :call nuwiki#commands#wiki_index(0)<CR>
nnoremap <silent><buffer> <Leader>wt :call nuwiki#commands#wiki_tab_index(0)<CR>
nnoremap <silent><buffer> <Leader>ws :call nuwiki#commands#wiki_ui_select()<CR>
nnoremap <silent><buffer> <Leader>wi :call nuwiki#commands#diary_index()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>w :call nuwiki#commands#diary_today()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>y :call nuwiki#commands#diary_yesterday()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>t :call nuwiki#commands#diary_tomorrow()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>m :call nuwiki#commands#diary_tomorrow()<CR>
nnoremap <silent><buffer> <Leader>w<Leader>i :call nuwiki#commands#diary_generate_index()<CR>
endif
" Links
nnoremap <silent><buffer> <CR> :call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <S-CR> :split<CR>:call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <C-CR> :vsplit<CR>:call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <C-S-CR> :tabnew<CR>:call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <BS> <C-o>
nnoremap <silent><buffer> <Tab> /\[\[<CR>:nohlsearch<CR>
nnoremap <silent><buffer> <S-Tab> ?\[\[<CR>:nohlsearch<CR>
nnoremap <silent><buffer> + :call nuwiki#commands#normalize_link()<CR>
xnoremap <silent><buffer> + :<C-u>call nuwiki#commands#normalize_link()<CR>
nnoremap <silent><buffer> <Leader>wn :call nuwiki#commands#wiki_goto_page('')<CR>
nnoremap <silent><buffer> <Leader>wd :call nuwiki#commands#delete_file()<CR>
nnoremap <silent><buffer> <Leader>wr :call nuwiki#commands#rename_file()<CR>
nnoremap <silent><buffer> <Leader>wc :call nuwiki#commands#colorize('')<CR>
xnoremap <silent><buffer> <Leader>wc :<C-u>call nuwiki#commands#colorize('')<CR>
if !get(g:, 'nuwiki_no_links_mappings', 0)
nnoremap <silent><buffer> <CR> :call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <S-CR> :split<CR>:call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <C-CR> :vsplit<CR>:call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <C-S-CR> :tabnew<CR>:call nuwiki#commands#follow_link_or_create()<CR>
nnoremap <silent><buffer> <BS> <C-o>
nnoremap <silent><buffer> <Tab> /\[\[<CR>:nohlsearch<CR>
nnoremap <silent><buffer> <S-Tab> ?\[\[<CR>:nohlsearch<CR>
nnoremap <silent><buffer> + :call nuwiki#commands#normalize_link()<CR>
xnoremap <silent><buffer> + :<C-u>call nuwiki#commands#normalize_link()<CR>
nnoremap <silent><buffer> <Leader>wn :call nuwiki#commands#wiki_goto_page('')<CR>
nnoremap <silent><buffer> <Leader>wd :call nuwiki#commands#delete_file()<CR>
nnoremap <silent><buffer> <Leader>wr :call nuwiki#commands#rename_file()<CR>
nnoremap <silent><buffer> <Leader>wc :call nuwiki#commands#colorize('')<CR>
xnoremap <silent><buffer> <Leader>wc :<C-u>call nuwiki#commands#colorize('')<CR>
endif
" Diary nav
nnoremap <silent><buffer> <C-Down> :call nuwiki#commands#diary_next()<CR>
nnoremap <silent><buffer> <C-Up> :call nuwiki#commands#diary_prev()<CR>
if !get(g:, 'nuwiki_no_diary_mappings', 0)
nnoremap <silent><buffer> <C-Down> :call nuwiki#commands#diary_next()<CR>
nnoremap <silent><buffer> <C-Up> :call nuwiki#commands#diary_prev()<CR>
endif
" Lists
nnoremap <silent><buffer> <C-Space> :call nuwiki#commands#toggle_list_item()<CR>
xnoremap <silent><buffer> <C-Space> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
nnoremap <silent><buffer> <C-@> :call nuwiki#commands#toggle_list_item()<CR>
xnoremap <silent><buffer> <C-@> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
nnoremap <silent><buffer> <Nul> :call nuwiki#commands#toggle_list_item()<CR>
xnoremap <silent><buffer> <Nul> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
nnoremap <silent><buffer> gnt :call nuwiki#commands#next_task()<CR>
nnoremap <silent><buffer> gln :call nuwiki#commands#cycle_list_item()<CR>
xnoremap <silent><buffer> gln :<C-u>call nuwiki#commands#cycle_list_item()<CR>
nnoremap <silent><buffer> glp :call nuwiki#commands#cycle_list_item_back()<CR>
xnoremap <silent><buffer> glp :<C-u>call nuwiki#commands#cycle_list_item_back()<CR>
nnoremap <silent><buffer> glx :call nuwiki#commands#reject_list_item()<CR>
xnoremap <silent><buffer> glx :<C-u>call nuwiki#commands#reject_list_item()<CR>
nnoremap <silent><buffer> glh :call nuwiki#commands#list_change_level(-1, 0)<CR>
nnoremap <silent><buffer> gll :call nuwiki#commands#list_change_level(1, 0)<CR>
nnoremap <silent><buffer> gLh :call nuwiki#commands#list_change_level(-1, 1)<CR>
nnoremap <silent><buffer> gLl :call nuwiki#commands#list_change_level(1, 1)<CR>
nnoremap <silent><buffer> glr :call nuwiki#commands#list_renumber()<CR>
nnoremap <silent><buffer> gLr :call nuwiki#commands#list_renumber_all()<CR>
nnoremap <silent><buffer> gl<Space> :call nuwiki#commands#list_remove_done()<CR>
nnoremap <silent><buffer> gL<Space> :call nuwiki#commands#list_remove_done_all()<CR>
nnoremap <silent><buffer> o :call nuwiki#commands#open_below_with_bullet()<CR>
nnoremap <silent><buffer> O :call nuwiki#commands#open_above_with_bullet()<CR>
if !get(g:, 'nuwiki_no_lists_mappings', 0)
nnoremap <silent><buffer> <C-Space> :call nuwiki#commands#toggle_list_item()<CR>
xnoremap <silent><buffer> <C-Space> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
nnoremap <silent><buffer> <C-@> :call nuwiki#commands#toggle_list_item()<CR>
xnoremap <silent><buffer> <C-@> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
nnoremap <silent><buffer> <Nul> :call nuwiki#commands#toggle_list_item()<CR>
xnoremap <silent><buffer> <Nul> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
nnoremap <silent><buffer> gnt :call nuwiki#commands#next_task()<CR>
nnoremap <silent><buffer> gln :call nuwiki#commands#cycle_list_item()<CR>
xnoremap <silent><buffer> gln :<C-u>call nuwiki#commands#cycle_list_item()<CR>
nnoremap <silent><buffer> glp :call nuwiki#commands#cycle_list_item_back()<CR>
xnoremap <silent><buffer> glp :<C-u>call nuwiki#commands#cycle_list_item_back()<CR>
nnoremap <silent><buffer> glx :call nuwiki#commands#reject_list_item()<CR>
xnoremap <silent><buffer> glx :<C-u>call nuwiki#commands#reject_list_item()<CR>
nnoremap <silent><buffer> glh :call nuwiki#commands#list_change_level(-1, 0)<CR>
nnoremap <silent><buffer> gll :call nuwiki#commands#list_change_level(1, 0)<CR>
nnoremap <silent><buffer> gLh :call nuwiki#commands#list_change_level(-1, 1)<CR>
nnoremap <silent><buffer> gLl :call nuwiki#commands#list_change_level(1, 1)<CR>
nnoremap <silent><buffer> glr :call nuwiki#commands#list_renumber()<CR>
nnoremap <silent><buffer> gLr :call nuwiki#commands#list_renumber_all()<CR>
nnoremap <silent><buffer> gl<Space> :call nuwiki#commands#list_remove_done()<CR>
nnoremap <silent><buffer> gL<Space> :call nuwiki#commands#list_remove_done_all()<CR>
nnoremap <silent><buffer> o :call nuwiki#commands#open_below_with_bullet()<CR>
nnoremap <silent><buffer> O :call nuwiki#commands#open_above_with_bullet()<CR>
" Insert-mode list editing (vimwiki parity).
inoremap <silent><buffer> <C-D> <C-o>:call nuwiki#commands#list_change_level(-1, 0)<CR>
inoremap <silent><buffer> <C-T> <C-o>:call nuwiki#commands#list_change_level(1, 0)<CR>
inoremap <silent><buffer> <C-L><C-J> <C-o>:call nuwiki#commands#list_cycle_symbol(1)<CR>
inoremap <silent><buffer> <C-L><C-K> <C-o>:call nuwiki#commands#list_cycle_symbol(-1)<CR>
inoremap <silent><buffer> <C-L><C-M> <C-o>:call nuwiki#commands#list_toggle_or_add_checkbox()<CR>
inoremap <silent><buffer><expr> <CR> nuwiki#commands#smart_return()
inoremap <silent><buffer><expr> <Tab> nuwiki#commands#smart_tab()
inoremap <silent><buffer><expr> <S-Tab> nuwiki#commands#smart_shift_tab()
" Insert-mode list editing (vimwiki parity).
inoremap <silent><buffer> <C-D> <C-o>:call nuwiki#commands#list_change_level(-1, 0)<CR>
inoremap <silent><buffer> <C-T> <C-o>:call nuwiki#commands#list_change_level(1, 0)<CR>
inoremap <silent><buffer> <C-L><C-J> <C-o>:call nuwiki#commands#list_cycle_symbol(1)<CR>
inoremap <silent><buffer> <C-L><C-K> <C-o>:call nuwiki#commands#list_cycle_symbol(-1)<CR>
inoremap <silent><buffer> <C-L><C-M> <C-o>:call nuwiki#commands#list_toggle_or_add_checkbox()<CR>
inoremap <silent><buffer><expr> <CR> nuwiki#commands#smart_return()
endif
" Headers
nnoremap <silent><buffer> = :call nuwiki#commands#heading_add()<CR>
nnoremap <silent><buffer> - :call nuwiki#commands#heading_remove()<CR>
nnoremap <silent><buffer> ]] :call nuwiki#commands#next_header()<CR>
nnoremap <silent><buffer> [[ :call nuwiki#commands#prev_header()<CR>
nnoremap <silent><buffer> ]= :call nuwiki#commands#next_sibling_header()<CR>
nnoremap <silent><buffer> [= :call nuwiki#commands#prev_sibling_header()<CR>
nnoremap <silent><buffer> ]u :call nuwiki#commands#parent_header()<CR>
nnoremap <silent><buffer> [u :call nuwiki#commands#parent_header()<CR>
if !get(g:, 'nuwiki_no_headers_mappings', 0)
nnoremap <silent><buffer> = :call nuwiki#commands#heading_add()<CR>
nnoremap <silent><buffer> - :call nuwiki#commands#heading_remove()<CR>
nnoremap <silent><buffer> ]] :call nuwiki#commands#next_header()<CR>
nnoremap <silent><buffer> [[ :call nuwiki#commands#prev_header()<CR>
nnoremap <silent><buffer> ]= :call nuwiki#commands#next_sibling_header()<CR>
nnoremap <silent><buffer> [= :call nuwiki#commands#prev_sibling_header()<CR>
nnoremap <silent><buffer> ]u :call nuwiki#commands#parent_header()<CR>
nnoremap <silent><buffer> [u :call nuwiki#commands#parent_header()<CR>
endif
" HTML export
nnoremap <silent><buffer> <Leader>wh :call nuwiki#commands#export_current()<CR>
nnoremap <silent><buffer> <Leader>whh :call nuwiki#commands#export_browse()<CR>
nnoremap <silent><buffer> <Leader>wha :call nuwiki#commands#export_all()<CR>
if !get(g:, 'nuwiki_no_html_export_mappings', 0)
nnoremap <silent><buffer> <Leader>wh :call nuwiki#commands#export_current()<CR>
nnoremap <silent><buffer> <Leader>whh :call nuwiki#commands#export_browse()<CR>
nnoremap <silent><buffer> <Leader>wha :call nuwiki#commands#export_all()<CR>
endif
" Mouse (opt-in via g:nuwiki_mouse_mappings = 1).
if get(g:, 'nuwiki_mouse_mappings', 0)
@@ -265,13 +278,17 @@ if !has('nvim')
nnoremap <silent><buffer> <RightMouse> <C-o>
endif
" Tables
nnoremap <silent><buffer> gqq :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> gq1 :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> gww :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> gw1 :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> <A-Left> :call nuwiki#commands#table_move_left()<CR>
nnoremap <silent><buffer> <A-Right> :call nuwiki#commands#table_move_right()<CR>
" Tables (and insert-mode table-cell navigation, same surface).
if !get(g:, 'nuwiki_no_table_editing_mappings', 0)
nnoremap <silent><buffer> gqq :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> gq1 :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> gww :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> gw1 :call nuwiki#commands#table_align()<CR>
nnoremap <silent><buffer> <A-Left> :call nuwiki#commands#table_move_left()<CR>
nnoremap <silent><buffer> <A-Right> :call nuwiki#commands#table_move_right()<CR>
inoremap <silent><buffer><expr> <Tab> nuwiki#commands#smart_tab()
inoremap <silent><buffer><expr> <S-Tab> nuwiki#commands#smart_shift_tab()
endif
" Folding — heading-block fold structure (matches lua/nuwiki/folding.lua).
" Opt-out via `let g:nuwiki_no_folding = 1` (mirrors the Lua-side
@@ -290,26 +307,28 @@ if !has('nvim')
" Text objects — vimwiki parity (matches lua/nuwiki/textobjects.lua).
" The `:<C-u>` clears any prefix count and the visual mode; the
" autoload function re-establishes the selection at the right range.
xnoremap <silent><buffer> ah :<C-u>call nuwiki#textobjects#heading(0, 0)<CR>
onoremap <silent><buffer> ah :<C-u>call nuwiki#textobjects#heading(0, 0)<CR>
xnoremap <silent><buffer> ih :<C-u>call nuwiki#textobjects#heading(1, 0)<CR>
onoremap <silent><buffer> ih :<C-u>call nuwiki#textobjects#heading(1, 0)<CR>
xnoremap <silent><buffer> aH :<C-u>call nuwiki#textobjects#heading(0, 1)<CR>
onoremap <silent><buffer> aH :<C-u>call nuwiki#textobjects#heading(0, 1)<CR>
xnoremap <silent><buffer> iH :<C-u>call nuwiki#textobjects#heading(1, 1)<CR>
onoremap <silent><buffer> iH :<C-u>call nuwiki#textobjects#heading(1, 1)<CR>
xnoremap <silent><buffer> al :<C-u>call nuwiki#textobjects#list_item(0)<CR>
onoremap <silent><buffer> al :<C-u>call nuwiki#textobjects#list_item(0)<CR>
xnoremap <silent><buffer> il :<C-u>call nuwiki#textobjects#list_item(1)<CR>
onoremap <silent><buffer> il :<C-u>call nuwiki#textobjects#list_item(1)<CR>
xnoremap <silent><buffer> a\ :<C-u>call nuwiki#textobjects#table_cell(0)<CR>
onoremap <silent><buffer> a\ :<C-u>call nuwiki#textobjects#table_cell(0)<CR>
xnoremap <silent><buffer> i\ :<C-u>call nuwiki#textobjects#table_cell(1)<CR>
onoremap <silent><buffer> i\ :<C-u>call nuwiki#textobjects#table_cell(1)<CR>
xnoremap <silent><buffer> ac :<C-u>call nuwiki#textobjects#table_column(0)<CR>
onoremap <silent><buffer> ac :<C-u>call nuwiki#textobjects#table_column(0)<CR>
xnoremap <silent><buffer> ic :<C-u>call nuwiki#textobjects#table_column(1)<CR>
onoremap <silent><buffer> ic :<C-u>call nuwiki#textobjects#table_column(1)<CR>
if !get(g:, 'nuwiki_no_text_objects_mappings', 0)
xnoremap <silent><buffer> ah :<C-u>call nuwiki#textobjects#heading(0, 0)<CR>
onoremap <silent><buffer> ah :<C-u>call nuwiki#textobjects#heading(0, 0)<CR>
xnoremap <silent><buffer> ih :<C-u>call nuwiki#textobjects#heading(1, 0)<CR>
onoremap <silent><buffer> ih :<C-u>call nuwiki#textobjects#heading(1, 0)<CR>
xnoremap <silent><buffer> aH :<C-u>call nuwiki#textobjects#heading(0, 1)<CR>
onoremap <silent><buffer> aH :<C-u>call nuwiki#textobjects#heading(0, 1)<CR>
xnoremap <silent><buffer> iH :<C-u>call nuwiki#textobjects#heading(1, 1)<CR>
onoremap <silent><buffer> iH :<C-u>call nuwiki#textobjects#heading(1, 1)<CR>
xnoremap <silent><buffer> al :<C-u>call nuwiki#textobjects#list_item(0)<CR>
onoremap <silent><buffer> al :<C-u>call nuwiki#textobjects#list_item(0)<CR>
xnoremap <silent><buffer> il :<C-u>call nuwiki#textobjects#list_item(1)<CR>
onoremap <silent><buffer> il :<C-u>call nuwiki#textobjects#list_item(1)<CR>
xnoremap <silent><buffer> a\ :<C-u>call nuwiki#textobjects#table_cell(0)<CR>
onoremap <silent><buffer> a\ :<C-u>call nuwiki#textobjects#table_cell(0)<CR>
xnoremap <silent><buffer> i\ :<C-u>call nuwiki#textobjects#table_cell(1)<CR>
onoremap <silent><buffer> i\ :<C-u>call nuwiki#textobjects#table_cell(1)<CR>
xnoremap <silent><buffer> ac :<C-u>call nuwiki#textobjects#table_column(0)<CR>
onoremap <silent><buffer> ac :<C-u>call nuwiki#textobjects#table_column(0)<CR>
xnoremap <silent><buffer> ic :<C-u>call nuwiki#textobjects#table_column(1)<CR>
onoremap <silent><buffer> ic :<C-u>call nuwiki#textobjects#table_column(1)<CR>
endif
endif
finish