feat(parity): close the entire P3 Commands section
CI / cargo fmt --check (push) Successful in 17s
CI / cargo clippy (push) Successful in 24s
CI / cargo test (push) Successful in 42s
CI / editor keymaps (push) Successful in 1m40s

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:
2026-06-03 01:23:07 +00:00
parent 3865b8bf0e
commit a11b742fc1
11 changed files with 334 additions and 52 deletions
+81
View File
@@ -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'
+14
View File
@@ -74,6 +74,20 @@ local function _setup_global_commands()
local function show_version() require('nuwiki.commands').show_version() end
vim.api.nvim_create_user_command('VimwikiShowVersion', show_version, {})
vim.api.nvim_create_user_command('NuwikiShowVersion', show_version, {})
-- Global Index / TabIndex entry points (upstream defines the Index family
-- globally). The buffer-local copies shadow these inside wiki buffers.
local function index(o) require('nuwiki.commands').wiki_index(o.count) end
local function tab_index(o) require('nuwiki.commands').wiki_tab_index(o.count) end
vim.api.nvim_create_user_command('VimwikiIndex', index, { count = 0 })
vim.api.nvim_create_user_command('NuwikiIndex', index, { count = 0 })
vim.api.nvim_create_user_command('VimwikiTabIndex', tab_index, { count = 0 })
vim.api.nvim_create_user_command('NuwikiTabIndex', tab_index, { count = 0 })
-- Get/set nuwiki client config (upstream's :VimwikiVar).
local function var(o) require('nuwiki.commands').var(o.args) end
vim.api.nvim_create_user_command('VimwikiVar', var, { nargs = '*' })
vim.api.nvim_create_user_command('NuwikiVar', var, { nargs = '*' })
end
function M.setup(opts)
+4 -4
View File
@@ -303,10 +303,10 @@ function M.attach(bufnr, mappings)
-- ===== Tables =====
if on('table_editing') then
map('n', 'gqq', cmd.table_align, { desc = 'nuwiki: align table' }, bufnr)
map('n', 'gq1', cmd.table_align, { desc = 'nuwiki: align table' }, bufnr)
map('n', 'gww', cmd.table_align, { desc = 'nuwiki: align table (wide)' }, bufnr)
map('n', 'gw1', cmd.table_align, { desc = 'nuwiki: align table (wide)' }, bufnr)
map('n', 'gqq', function() cmd.table_align_or_cmd('gqq') end, { desc = 'nuwiki: align table / gqq' }, bufnr)
map('n', 'gq1', function() cmd.table_align_or_cmd('gqq') end, { desc = 'nuwiki: align table / gqq' }, bufnr)
map('n', 'gww', function() cmd.table_align_or_cmd('gww') end, { desc = 'nuwiki: align table / gww' }, bufnr)
map('n', 'gw1', function() cmd.table_align_or_cmd('gww') end, { desc = 'nuwiki: align table / gww' }, bufnr)
map('n', '<A-Left>', cmd.table_move_column_left, { desc = 'nuwiki: move column left' }, bufnr)
map('n', '<A-Right>', cmd.table_move_column_right, { desc = 'nuwiki: move column right' }, bufnr)
end