feat(keymaps): configurable map_prefix for the wiki command family (P2)
CI / cargo fmt --check (push) Failing after 33s
CI / cargo clippy (push) Successful in 31s
CI / cargo test (push) Successful in 41s
CI / editor keymaps (push) Successful in 1m49s

Mirror vimwiki's g:vimwiki_map_prefix. The whole <Leader>w* family was
hardcoded across the map layer; it is now built from a configurable prefix:

- Neovim: `map_prefix` setup() option (default '<Leader>w'), read by
  lua/nuwiki/keymaps.lua (buffer-local) and lua/nuwiki/init.lua (global
  entry points).
- Vim: g:nuwiki_map_prefix, applied via :exe in plugin/nuwiki.vim (global)
  and ftplugin/vimwiki.vim (buffer-local).

Setting a custom prefix relocates <prefix>{w,t,s,i,n,d,r,c,h,hh,ha} and
<prefix><Leader>{w,y,t,m,i}, leaving nothing under the old <Leader>w*.
Non-prefix maps (<CR>, gl*, headers, …) are untouched.

Tests: new test-keymaps-vim-prefix.vim harness (21 cases, wired into
test-keymaps-vim.sh) + map_prefix.relocates_wiki_family in test-keymaps.lua.
Docs: README, doc/nuwiki.txt, lua config comment, vimwiki-gap.md ticked.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 19:18:06 +00:00
parent 23aec3e6c7
commit feedd30c4d
11 changed files with 234 additions and 55 deletions
+16
View File
@@ -103,6 +103,7 @@ default): >
file_extension = '.wiki',
syntax = 'vimwiki',
log_level = 'warn',
map_prefix = '<Leader>w',
})
<For multiple wikis or per-wiki tuning, use the `wikis` list: >
@@ -132,6 +133,7 @@ plugin: >
let g:nuwiki_wiki_root = '~/vimwiki'
let g:nuwiki_file_extension = '.wiki'
let g:nuwiki_log_level = 'warn'
let g:nuwiki_map_prefix = '<Leader>w'
<Top-level options ~
@@ -152,6 +154,12 @@ plugin: >
`log_level` warn
`error` | `warn` | `info` | `debug`. Forwarded to the language server.
*nuwiki-config-map-prefix*
`map_prefix` '<Leader>w'
Prefix for the wiki command family (`<prefix>w`, `<prefix>t`,
`<prefix><Leader>w`, …). Mirrors vimwiki's `g:vimwiki_map_prefix`. Vim
users set |g:nuwiki_map_prefix| instead.
*nuwiki-config-folding*
`folding` 'lsp'
`lsp` uses the server's `foldingRange` provider (Neovim 0.11+ wires
@@ -253,6 +261,14 @@ Vim-specific globals ~
`html_export` `<Leader>wh`, `<Leader>whh`, `<Leader>wha`
`text_objects` `ah`, `ih`, `al`, `il`, `a\`, `i\`, `ac`, `ic`
*g:nuwiki_map_prefix*
`g:nuwiki_map_prefix` `'<Leader>w'`
Prefix for the wiki command family — both the global entry-point maps
(`<prefix>w`, `<prefix>t`, `<prefix>s`, `<prefix>i`, `<prefix><Leader>{w,y,
t,m,i}`) and the buffer-local ones (`<prefix>{n,d,r,c,h,hh,ha}`). Mirrors
vimwiki's `g:vimwiki_map_prefix`. Set it before the plugin loads. Neovim
users set the `map_prefix` option in `setup()` instead.
*g:nuwiki_no_folding*
`g:nuwiki_no_folding` 0
When 1, the Vim path skips `foldexpr` / `foldmethod` setup.