feat(parity): close the entire P3 Commands section
All six remaining command gaps (client-side; no server change):
- VimwikiRenameFile: bare -> -nargs=? (arg accepted-ignored; rename still
delegates to the LSP rename prompt). No more E488.
- VimwikiVar / NuwikiVar: get/set the client config (upstream vimwiki#vars#cmd).
No arg prints config (Vim: g:nuwiki_*; Neovim: resolved setup() opts), one arg
gets a key, two+ sets it. Global command, both clients.
- VimwikiReturn / NuwikiReturn: command form of the smart <CR> continuation —
enters insert at EOL and fires the <CR> mapping (return_cmd / vimwiki_return).
Upstream's mode-flag args accepted but unused.
- VimwikiTableAlignQ vs AlignW: corrected — upstream's gqq/gww are identical on
a table; the only difference is the non-table fallback (native `normal! gqq`
vs `gww`). New table_align_or_cmd(cmd) aligns on a table row, else runs
`normal! <cmd>`. Q/gqq/gq1 -> gqq; W/gww/gw1 -> gww; NuwikiTableAlign -> gqq.
- VimwikiSearch / VWS: scope the lvimgrep to the current wiki's root (resolved
client-side) over <root>/**/*<ext>, not CWD `**`; empty pattern reuses the
last search. Both clients.
- VimwikiIndex family: add global Vimwiki/NuwikiIndex + TabIndex entry points
(plugin/nuwiki.vim + init.lua _setup_global_commands, with -count), so a wiki
opens from any buffer. Buffer-local copies still shadow inside wiki buffers.
Tests: surface.{Vimwiki,Nuwiki}{Return,Var}, cmd.VimwikiVar_sets_*,
cmd.global_entry_points (both harnesses). Docs (README + doc/nuwiki.txt) and the
gap doc updated. Neovim 299, Vim 291/18/21 pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -175,6 +175,66 @@ function! nuwiki#commands#show_version() abort
|
||||
echo (has('nvim') ? 'Neovim' : 'Vim') . ': ' . v:version
|
||||
endfunction
|
||||
|
||||
" :VimwikiSearch / :VWS {pattern} — search the current wiki's files (upstream's
|
||||
" search scopes to the wiki, not the editor's CWD). Resolves the wiki whose root
|
||||
" contains the current file; falls back to the first configured wiki, then to
|
||||
" the CWD. An empty pattern reuses the last search (`@/`). Populates the
|
||||
" location list.
|
||||
function! nuwiki#commands#search(args) abort
|
||||
let l:pat = a:args ==# '' ? @/ : a:args
|
||||
if l:pat ==# ''
|
||||
echohl WarningMsg | echom 'nuwiki: no search pattern' | echohl None
|
||||
return
|
||||
endif
|
||||
" Resolve { root, ext } for the current buffer's wiki.
|
||||
let l:file = expand('%:p')
|
||||
let l:root = ''
|
||||
let l:ext = get(g:, 'nuwiki_file_extension', '.wiki')
|
||||
for l:w in nuwiki#commands#wiki_list()
|
||||
let l:wroot = fnamemodify(expand(l:w.root), ':p')
|
||||
if l:file[: len(l:wroot) - 1] ==# l:wroot
|
||||
let l:root = l:wroot
|
||||
let l:ext = get(l:w, 'ext', l:ext)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if l:root ==# '' && !empty(nuwiki#commands#wiki_list())
|
||||
let l:first = nuwiki#commands#wiki_list()[0]
|
||||
let l:root = fnamemodify(expand(l:first.root), ':p')
|
||||
let l:ext = get(l:first, 'ext', l:ext)
|
||||
endif
|
||||
let l:ext = l:ext[0] ==# '.' ? l:ext : '.' . l:ext
|
||||
let l:glob = l:root ==# '' ? '**' : fnameescape(l:root) . '**/*' . l:ext
|
||||
execute 'lvimgrep /' . escape(l:pat, '/') . '/j ' . l:glob
|
||||
lopen
|
||||
endfunction
|
||||
|
||||
" :VimwikiVar / :NuwikiVar [key [value]] — get/set the nuwiki client globals
|
||||
" (g:nuwiki_*), mirroring upstream's vimwiki#vars#cmd. No arg prints every
|
||||
" g:nuwiki_* var; one arg prints that var; two+ sets it (as a string — server-
|
||||
" backed settings need a restart to take effect, which we note).
|
||||
function! nuwiki#commands#var(arg) abort
|
||||
let l:parts = split(a:arg, '\s\+')
|
||||
if empty(l:parts)
|
||||
let l:keys = sort(filter(keys(g:), 'v:val =~# "^nuwiki_"'))
|
||||
if empty(l:keys)
|
||||
echo 'nuwiki: no g:nuwiki_* variables set'
|
||||
return
|
||||
endif
|
||||
for l:k in l:keys
|
||||
echo printf('g:%s = %s', l:k, string(g:[l:k]))
|
||||
endfor
|
||||
return
|
||||
endif
|
||||
let l:key = 'nuwiki_' . substitute(l:parts[0], '^nuwiki_', '', '')
|
||||
if len(l:parts) == 1
|
||||
echo printf('g:%s = %s', l:key, exists('g:' . l:key) ? string(g:[l:key]) : '(unset)')
|
||||
else
|
||||
let g:[l:key] = join(l:parts[1:], ' ')
|
||||
echo printf('set g:%s = %s (restart for server-backed settings)', l:key, string(g:[l:key]))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#wiki_ui_select() abort
|
||||
let l:wikis = nuwiki#commands#wiki_list()
|
||||
if empty(l:wikis)
|
||||
@@ -929,6 +989,18 @@ function! nuwiki#commands#table_align() abort
|
||||
call s:exec('nuwiki.table.align', l:args)
|
||||
endfunction
|
||||
|
||||
" Upstream `gqq` (AlignQ) / `gww` (AlignW): on a table row, align the table;
|
||||
" otherwise fall back to the native Vim format command (`normal! gqq` keeps the
|
||||
" cursor free; `gww` keeps the cursor in place). `normal!` bypasses our own
|
||||
" mapping so there's no recursion.
|
||||
function! nuwiki#commands#table_align_or_cmd(cmd) abort
|
||||
if s:is_table_row(getline('.'))
|
||||
call nuwiki#commands#table_align()
|
||||
else
|
||||
execute 'normal! ' . a:cmd
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! nuwiki#commands#table_move_left() abort
|
||||
let l:p = s:cursor_position()
|
||||
let l:args = [{
|
||||
@@ -1233,6 +1305,15 @@ function! nuwiki#commands#smart_return() abort
|
||||
return "\<CR>"
|
||||
endfunction
|
||||
|
||||
" :VimwikiReturn / :NuwikiReturn — the command form of the smart `<CR>`
|
||||
" continuation (upstream's mapping-driven `VimwikiReturn`). Enters insert at
|
||||
" end of line and triggers the buffer-local `<CR>` mapping (smart_return),
|
||||
" continuing the list item / table row. Args mirror upstream's mode flags and
|
||||
" are accepted but unused (the continuation is inferred from the line).
|
||||
function! nuwiki#commands#return_cmd(...) abort
|
||||
call feedkeys("A\<CR>", 'm')
|
||||
endfunction
|
||||
|
||||
" Insert-mode `<Tab>` / `<S-Tab>` table navigation — vimwiki parity.
|
||||
" Used as `<expr>` mappings so we can pass `<Tab>` / `<S-Tab>` through
|
||||
" verbatim when the cursor isn't on a table row.
|
||||
|
||||
Reference in New Issue
Block a user