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:
@@ -285,6 +285,67 @@ function M.show_version()
|
||||
}, false, {})
|
||||
end
|
||||
|
||||
-- :VimwikiSearch / :VWS {pattern} — search the current wiki's files (upstream
|
||||
-- scopes to the wiki, not the editor CWD). Resolves the wiki whose root holds
|
||||
-- the current file, else the first configured wiki, else CWD. Empty pattern
|
||||
-- reuses the last search. Populates the location list.
|
||||
function M.search(args)
|
||||
local pat = (args == nil or args == '') and vim.fn.getreg('/') or args
|
||||
if pat == '' then
|
||||
vim.notify('nuwiki: no search pattern', vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
local config = require('nuwiki.config')
|
||||
local file = vim.fn.expand('%:p')
|
||||
local root, ext = '', '.wiki'
|
||||
for _, w in ipairs(config.wiki_list()) do
|
||||
local wroot = vim.fn.fnamemodify(vim.fn.expand(w.root), ':p')
|
||||
if file:sub(1, #wroot) == wroot then
|
||||
root, ext = wroot, w.ext or ext
|
||||
break
|
||||
end
|
||||
end
|
||||
if root == '' then
|
||||
local first = config.wiki_list()[1]
|
||||
if first then
|
||||
root = vim.fn.fnamemodify(vim.fn.expand(first.root), ':p')
|
||||
ext = first.ext or ext
|
||||
end
|
||||
end
|
||||
if not ext:match('^%.') then ext = '.' .. ext end
|
||||
local glob = root == '' and '**' or (vim.fn.fnameescape(root) .. '**/*' .. ext)
|
||||
vim.cmd('lvimgrep /' .. vim.fn.escape(pat, '/') .. '/j ' .. glob)
|
||||
vim.cmd('lopen')
|
||||
end
|
||||
|
||||
-- :VimwikiVar / :NuwikiVar [key [value]] — get/set the nuwiki client config
|
||||
-- (upstream's vimwiki#vars#cmd). No arg prints the resolved setup options; one
|
||||
-- arg prints that key; two+ sets it on the in-memory options (server-backed
|
||||
-- settings need a restart).
|
||||
function M.var(arg)
|
||||
local parts = vim.split(arg or '', '%s+', { trimempty = true })
|
||||
local opts = require('nuwiki.config').options
|
||||
if #parts == 0 then
|
||||
local keys = vim.tbl_keys(opts)
|
||||
table.sort(keys)
|
||||
local lines = {}
|
||||
for _, k in ipairs(keys) do
|
||||
lines[#lines + 1] = { string.format('%s = %s\n', k, vim.inspect(opts[k])) }
|
||||
end
|
||||
vim.api.nvim_echo(lines, false, {})
|
||||
return
|
||||
end
|
||||
local key = parts[1]
|
||||
if #parts == 1 then
|
||||
vim.api.nvim_echo({ { string.format('%s = %s', key, vim.inspect(opts[key])) } }, false, {})
|
||||
else
|
||||
opts[key] = table.concat(parts, ' ', 2)
|
||||
vim.api.nvim_echo({ {
|
||||
string.format('set %s = %s (restart for server-backed settings)', key, vim.inspect(opts[key])),
|
||||
} }, false, {})
|
||||
end
|
||||
end
|
||||
|
||||
function M.wiki_ui_select()
|
||||
local wikis = require('nuwiki.config').wiki_list()
|
||||
if #wikis == 0 then
|
||||
@@ -935,6 +996,15 @@ function M.smart_return()
|
||||
return cr
|
||||
end
|
||||
|
||||
-- :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). Args
|
||||
-- mirror upstream's mode flags and are unused (continuation is inferred).
|
||||
function M.vimwiki_return()
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes('A<CR>', true, false, true), 'm', false)
|
||||
end
|
||||
|
||||
--- Insert-mode `<Tab>` / `<S-Tab>` table navigation — vimwiki parity.
|
||||
--- Used as `<expr>` keymaps so we can fall back to a literal `<Tab>` /
|
||||
--- `<S-Tab>` when the cursor isn't on a table row. Inside a row both
|
||||
@@ -1026,6 +1096,17 @@ function M.table_align()
|
||||
exec('nuwiki.table.align', pos_args())
|
||||
end
|
||||
|
||||
-- Upstream `gqq` (AlignQ) / `gww` (AlignW): on a table row, align the table;
|
||||
-- otherwise fall back to the native Vim format command (`normal! gqq`/`gww`).
|
||||
-- `normal!` bypasses our mapping so there's no recursion.
|
||||
function M.table_align_or_cmd(cmd)
|
||||
if is_table_row(vim.api.nvim_get_current_line()) then
|
||||
M.table_align()
|
||||
else
|
||||
vim.cmd('normal! ' .. cmd)
|
||||
end
|
||||
end
|
||||
|
||||
function M.table_move_column_left()
|
||||
local p = pos_args()[1]
|
||||
p.dir = 'left'
|
||||
|
||||
Reference in New Issue
Block a user