feat(mappings): vimwiki-parity default keymaps for Vim + Neovim
The Phase 19 keymap layer only covered the high-value subset and used `g=`/`g-` instead of vimwiki's `=`/`-` for header levels. Users reporting "mappings don't seem to be working" were either on the Vim path (which registered zero keymaps) or hitting bindings that don't exist (e.g. `<Tab>`, `<S-CR>`, `gll`, `gqq`). Cross-referenced upstream vimwiki/ftplugin/vimwiki.vim and rewired both `lua/nuwiki/keymaps.lua` and `ftplugin/vimwiki.vim` (Vim path) to match its default surface. Mappings backed by commands that exist on the server dispatch directly; §13.1-deferred mappings register with the same lhs but stub out to a notification — so users get parity *signalling*, not silence. New on Neovim (and matched on Vim where possible): Links group: - `<S-CR>` / `<C-CR>` / `<C-S-CR>` — follow in split / vsplit / tab - `<Tab>` / `<S-Tab>` — jump to next / prev `[[…]]` (pure Lua search) - `+` (n + x) — :VimwikiNormalizeLink stub - `<Leader>wc` (n + x) — :VimwikiColorize stub Lists group: - `<C-@>` (n + x) — terminal-alt for `<C-Space>` - `gln` / `glp` increment + decrement (deferred backward; same fn for now) - `glh` / `gll` / `gLh` / `gLl` — list level stubs - `glr` / `gLr` — list renumber stubs - `gl<Space>` / `gL<Space>` — checkbox remove stubs - `o` / `O` — open below/above and continue the bullet (pure Lua) - visual-mode variants of `<C-Space>`, `gln`, `glp`, `glx` Header group (key group, now buffer-local): - `=` / `-` — promote / demote (was `g=`/`g-`, matched to vimwiki) - `]]` / `[[` — next / prev header (pure Lua) - `]=` / `[=` — next / prev sibling header (pure Lua) - `]u` / `[u` — parent header (pure Lua) Table group: `gqq`, `gq1`, `gww`, `gw1`, `<A-Left>`, `<A-Right>` stubs. Wiki prefix: `<Leader>w<Leader>m` (vimwiki's tomorrow), `<Leader>w<Leader>i` (rebuild diary index). Config schema (`config.options.mappings`) updates to vimwiki's group names — `links` / `lists` / `headers` / `table_editing` / `diary` / `html_export` / `text_objects` / `wiki_prefix`. Old names (`list_editing` / `header_nav`) are retired; rename only — keeps the opt-out shape intact. Vim path: same set ported to buffer-local VimL maps. `g:nuwiki_no_default_mappings` opts out the whole layer for users who prefer their own bindings. Lua side uses the Neovim 0.11+ `vim.keymap.set` API; both call straight into the same `nuwiki#commands#…` autoload (Vim) / `nuwiki.commands` (Lua) layer that drives the LSP. Total 377 tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,74 @@ if !has('nvim')
|
||||
command! -buffer -nargs=? NuwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
|
||||
command! -buffer -nargs=1 NuwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
|
||||
|
||||
" ===== 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.
|
||||
|
||||
if !get(g:, 'nuwiki_no_default_mappings', 0)
|
||||
" Wiki prefix
|
||||
nnoremap <silent><buffer> <Leader>ww :call nuwiki#commands#diary_today()<CR>
|
||||
nnoremap <silent><buffer> <Leader>wt :call nuwiki#commands#diary_today()<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>
|
||||
|
||||
" Links
|
||||
nnoremap <silent><buffer> <CR> :LspDefinition<CR>
|
||||
nnoremap <silent><buffer> <S-CR> :split<CR>:LspDefinition<CR>
|
||||
nnoremap <silent><buffer> <C-CR> :vsplit<CR>:LspDefinition<CR>
|
||||
nnoremap <silent><buffer> <C-S-CR> :tabnew<CR>:LspDefinition<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> + :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiNormalizeLink not yet implemented — see SPEC §13.1'<bar>echohl None<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 :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiColorize not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
|
||||
" Diary nav
|
||||
nnoremap <silent><buffer> <C-Down> :call nuwiki#commands#diary_next()<CR>
|
||||
nnoremap <silent><buffer> <C-Up> :call nuwiki#commands#diary_prev()<CR>
|
||||
|
||||
" 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> gnt :call nuwiki#commands#next_task()<CR>
|
||||
nnoremap <silent><buffer> gln :call nuwiki#commands#cycle_list_item()<CR>
|
||||
nnoremap <silent><buffer> glp :call nuwiki#commands#cycle_list_item()<CR>
|
||||
nnoremap <silent><buffer> glx :call nuwiki#commands#reject_list_item()<CR>
|
||||
nnoremap <silent><buffer> glh :echohl WarningMsg<bar>echom 'nuwiki: list level not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> gll :echohl WarningMsg<bar>echom 'nuwiki: list level not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> gLh :echohl WarningMsg<bar>echom 'nuwiki: list level subtree not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> gLl :echohl WarningMsg<bar>echom 'nuwiki: list level subtree not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> glr :echohl WarningMsg<bar>echom 'nuwiki: list renumber not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> gLr :echohl WarningMsg<bar>echom 'nuwiki: list renumber-all not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
|
||||
" Headers
|
||||
nnoremap <silent><buffer> = :call nuwiki#commands#heading_add()<CR>
|
||||
nnoremap <silent><buffer> - :call nuwiki#commands#heading_remove()<CR>
|
||||
nnoremap <silent><buffer> ]] /^\s*=\+\s<CR>:nohlsearch<CR>
|
||||
nnoremap <silent><buffer> [[ ?^\s*=\+\s<CR>:nohlsearch<CR>
|
||||
|
||||
" 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>
|
||||
|
||||
" Tables (deferred §13.1)
|
||||
nnoremap <silent><buffer> gqq :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiTableAlignQ not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> gww :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiTableAlignW not yet implemented — see SPEC §13.1'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> <A-Left> :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiTableMoveColumnLeft not yet implemented'<bar>echohl None<CR>
|
||||
nnoremap <silent><buffer> <A-Right> :echohl WarningMsg<bar>echom 'nuwiki: :VimwikiTableMoveColumnRight not yet implemented'<bar>echohl None<CR>
|
||||
endif
|
||||
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user