fix(parity): fifth-pass re-audit — VimwikiGoto nargs, autowriteall, table_auto_fmt
Closes the actionable fifth-pass findings (gap doc updated): - VimwikiGoto / NuwikiGoto: -nargs=1 -> -nargs=* in all four defs. Was a real bug — `:VimwikiGoto` raised E471, `:VimwikiGoto My Page` raised E488, and the handler's empty-arg prompt fallback was unreachable. Both clients already prompt on empty, so -nargs=* (keeping -complete=pages) restores upstream behavior. - autowriteall (upstream default ON): while a wiki buffer is current, mirror Vim's global 'autowriteall' (auto-save on page switch / :make), restoring the prior value on leave. Neovim via ftplugin.lua setup_autowriteall (BufEnter/BufLeave) gated by the `autowriteall` setup option; Vim via the NuwikiAutoWriteAll augroup gated by g:nuwiki_autowriteall. - table_auto_fmt (upstream default ON): re-align the table under the cursor on InsertLeave. Both clients, gated by `table_auto_fmt` / g:nuwiki_table_auto_fmt, guarded on the cursor line containing `|` before the async table_align. Also logged (no code): VimwikiRenameFile missing -nargs=? (subsumed by the LSP-rename divergence), table_reduce_last_col, user_htmls, hl_headers/ hl_cb_checked, and a commentstring value-mismatch note. Mappings audit clean. The Neovim harness disables table_auto_fmt in setup (its async re-align would perturb the deterministic table-nav keystroke cases); its wiring is verified on a throwaway scratch buffer instead. Docs (README + doc/nuwiki.txt) updated. Tests: cmd.VimwikiGoto_accepts_multiword, config.autowriteall_applied, config.table_auto_fmt_autocmd. Neovim 293, Vim 285/18/21 pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,15 @@ M.defaults = {
|
||||
-- back to a regex-based `foldexpr`. `'off'` skips folding setup.
|
||||
folding = 'lsp',
|
||||
|
||||
-- vimwiki `autowriteall` (default on): while a wiki buffer is current,
|
||||
-- mirror Vim's global `'autowriteall'` so a modified buffer auto-saves on
|
||||
-- page switch / `:make` etc., restoring the prior value on leave.
|
||||
autowriteall = true,
|
||||
|
||||
-- vimwiki `table_auto_fmt` (default on): re-align the table under the
|
||||
-- cursor when leaving insert mode.
|
||||
table_auto_fmt = true,
|
||||
|
||||
-- Broken-link diagnostic severity. Sent to the server, which downgrades
|
||||
-- or suppresses the diagnostic accordingly.
|
||||
-- 'off' | 'hint' | 'warn' | 'error'
|
||||
|
||||
@@ -46,6 +46,54 @@ local function setup_folding(bufnr, folding_mode)
|
||||
})
|
||||
end
|
||||
|
||||
-- vimwiki `autowriteall`: while this wiki buffer is current, mirror the option
|
||||
-- into Vim's global 'autowriteall' (auto-save on switch/make), restoring the
|
||||
-- prior value on leave.
|
||||
local function setup_autowriteall(bufnr, enabled)
|
||||
if not enabled then
|
||||
return
|
||||
end
|
||||
if bufnr == 0 then
|
||||
bufnr = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
local grp = vim.api.nvim_create_augroup('nuwiki_awa_' .. bufnr, { clear = true })
|
||||
local function enter()
|
||||
vim.b[bufnr].nuwiki_awa_saved = vim.o.autowriteall
|
||||
vim.o.autowriteall = true
|
||||
end
|
||||
local function leave()
|
||||
local saved = vim.b[bufnr].nuwiki_awa_saved
|
||||
if saved ~= nil then
|
||||
vim.o.autowriteall = saved
|
||||
end
|
||||
end
|
||||
vim.api.nvim_create_autocmd('BufEnter', { buffer = bufnr, group = grp, callback = enter })
|
||||
vim.api.nvim_create_autocmd('BufLeave', { buffer = bufnr, group = grp, callback = leave })
|
||||
-- FileType fires after the initial BufEnter, so apply once now too.
|
||||
enter()
|
||||
end
|
||||
|
||||
-- vimwiki `table_auto_fmt`: re-align the table under the cursor on InsertLeave.
|
||||
local function setup_table_auto_fmt(bufnr, enabled)
|
||||
if not enabled then
|
||||
return
|
||||
end
|
||||
if bufnr == 0 then
|
||||
bufnr = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
local grp = vim.api.nvim_create_augroup('nuwiki_taf_' .. bufnr, { clear = true })
|
||||
vim.api.nvim_create_autocmd('InsertLeave', {
|
||||
buffer = bufnr,
|
||||
group = grp,
|
||||
callback = function()
|
||||
-- Cheap guard: only round-trip to the server on a table row.
|
||||
if vim.api.nvim_get_current_line():find('|', 1, true) then
|
||||
require('nuwiki.commands').table_align()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function M.attach(bufnr)
|
||||
bufnr = bufnr or 0
|
||||
local config = require('nuwiki.config')
|
||||
@@ -59,6 +107,8 @@ function M.attach(bufnr)
|
||||
end
|
||||
|
||||
setup_folding(bufnr, opts.folding or 'lsp')
|
||||
setup_autowriteall(bufnr, opts.autowriteall ~= false)
|
||||
setup_table_auto_fmt(bufnr, opts.table_auto_fmt ~= false)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user