From 3865b8bf0e441713ecb59f6d2220361fa79c990a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Wed, 3 Jun 2026 00:59:33 +0000 Subject: [PATCH] =?UTF-8?q?fix(parity):=20fifth-pass=20re-audit=20?= =?UTF-8?q?=E2=80=94=20VimwikiGoto=20nargs,=20autowriteall,=20table=5Fauto?= =?UTF-8?q?=5Ffmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- README.md | 9 ++++ development/tests/test-keymaps-vim.vim | 26 +++++++++++ development/tests/test-keymaps.lua | 28 +++++++++++ development/tests/test-keymaps.sh | 10 +++- development/vimwiki-gap.md | 65 +++++++++++++++++++++++++- doc/nuwiki.txt | 14 ++++++ ftplugin/vimwiki.vim | 35 ++++++++++++-- lua/nuwiki/config.lua | 9 ++++ lua/nuwiki/ftplugin.lua | 50 ++++++++++++++++++++ 9 files changed, 239 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ce82797..4ac62b3 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,11 @@ require('nuwiki').setup({ -- 'lsp' (server-driven foldingRange, default) | 'expr' (regex) | 'off'. folding = 'lsp', + -- Mirror Vim's &autowriteall while in a wiki buffer (auto-save on switch). + autowriteall = true, + -- Re-align the table under the cursor on InsertLeave. + table_auto_fmt = true, + -- Broken-link diagnostic severity: 'off' | 'hint' | 'warn' | 'error'. diagnostic = { link_severity = 'warn', @@ -283,6 +288,8 @@ let g:nuwiki_link_severity = 'warn' " 'off'|'hint'|'warn'|'error' let g:nuwiki_no_default_mappings = 0 " set to 1 to skip the keymap layer let g:nuwiki_map_prefix = 'w' " wiki command prefix let g:nuwiki_no_folding = 0 " set to 1 to skip foldexpr setup +let g:nuwiki_autowriteall = 1 " set to 0 to not touch &autowriteall +let g:nuwiki_table_auto_fmt = 1 " set to 0 to skip InsertLeave table re-align let g:nuwiki_mouse_mappings = 0 " set to 1 to enable mouse maps " Drop individual keymap subgroups (mirror the Lua `mappings.` toggles): " g:nuwiki_no_{wiki_prefix,links,lists,headers,table_editing,diary,html_export,text_objects}_mappings @@ -300,6 +307,8 @@ let g:nuwiki_mouse_mappings = 0 " set to 1 to enable mouse maps | `log_level` | string | `'warn'` | `'error'` \| `'warn'` \| `'info'` \| `'debug'` | | `map_prefix` | string | `'w'` | prefix for the wiki command family (`w`, `t`, `w`, …); mirrors vimwiki's `g:vimwiki_map_prefix`. Vim users set `g:nuwiki_map_prefix` | | `folding` | string | `'lsp'` | `'lsp'` \| `'expr'` \| `'off'` | +| `autowriteall` | bool | `true` | mirror Vim's `'autowriteall'` while in a wiki buffer (vimwiki `autowriteall`); Vim users set `g:nuwiki_autowriteall` | +| `table_auto_fmt` | bool | `true` | re-align the table under the cursor on `InsertLeave` (vimwiki `table_auto_fmt`); Vim users set `g:nuwiki_table_auto_fmt` | | `wikis` | list of tables | `nil` | per-wiki tables (see below); wins over the single-wiki shorthand | | `mappings` | table | all on | keymap subgroups (see below) | | `diagnostic` | table | `{ link_severity = 'warn' }` | `link_severity`: `'off'` \| `'hint'` \| `'warn'` \| `'error'` | diff --git a/development/tests/test-keymaps-vim.vim b/development/tests/test-keymaps-vim.vim index b0a6d37..8613b05 100644 --- a/development/tests/test-keymaps-vim.vim +++ b/development/tests/test-keymaps-vim.vim @@ -692,6 +692,32 @@ call s:record( \ 'cmd.search_and_tablealign_nargs', \ 'err=' . s:attr_err) +" ===== :VimwikiGoto -nargs=* ===== +" Was -nargs=1, so a page name with a space raised E488 (and the empty-arg +" prompt fallback was unreachable). Now -nargs=*: a multi-word arg must parse. +" The goto is an LSP roundtrip (no server here); swallow non-attribute errors. +let s:goto_err = '' +try + silent! VimwikiGoto My Page +catch /E471\|E488/ + let s:goto_err = v:exception +catch + " no-LSP / not-found errors are expected and fine here. +endtry +call s:record( + \ s:goto_err ==# '' ? 1 : 0, + \ 'cmd.VimwikiGoto_accepts_multiword', + \ 'err=' . s:goto_err) + +" ===== autowriteall / table_auto_fmt (Vim path) ===== +" autowriteall (default on) sets Vim's global &autowriteall on the wiki buffer. +call s:record(&autowriteall ? 1 : 0, 'config.autowriteall_applied', + \ '&autowriteall=' . &autowriteall) +" table_auto_fmt (default on) registers the NuwikiTableAutoFmt InsertLeave group. +call s:record(exists('#NuwikiTableAutoFmt#InsertLeave') ? 1 : 0, + \ 'config.table_auto_fmt_autocmd', + \ exists('#NuwikiTableAutoFmt#InsertLeave') ? '' : 'no InsertLeave autocmd') + " ===== :VimwikiRemoveDone -bang -range ===== " Upstream is `-range`; nuwiki had `-bang` only, so `:'<,'>VimwikiRemoveDone` " raised E481. Now `-bang -range`: a ranged invocation must parse (no E481), diff --git a/development/tests/test-keymaps.lua b/development/tests/test-keymaps.lua index 44d0d7c..a9fec19 100644 --- a/development/tests/test-keymaps.lua +++ b/development/tests/test-keymaps.lua @@ -255,6 +255,34 @@ vim.defer_fn(function() end end + -- ===== Config-driven buffer behaviors ===== + -- autowriteall (default on) mirrors into Vim's global 'autowriteall' while + -- the wiki buffer is current. + record(vim.o.autowriteall == true, 'config.autowriteall_applied', + vim.o.autowriteall and '' or 'autowriteall not set on the wiki buffer') + -- table_auto_fmt wiring: with the option enabled, attaching a buffer + -- registers a buffer-local InsertLeave autocmd. (It's off in the harness + -- setup so the async re-align doesn't perturb the table-nav cases below, so + -- verify on a throwaway scratch buffer in its own window.) + do + local cfg = require('nuwiki.config') + cfg.options.table_auto_fmt = true + vim.cmd('new') + local sbuf = vim.api.nvim_get_current_buf() + require('nuwiki.ftplugin').attach(sbuf) + local found = false + for _, a in ipairs(vim.api.nvim_get_autocmds({ event = 'InsertLeave', buffer = sbuf })) do + if a.group_name and a.group_name:match('^nuwiki_taf_') then + found = true + break + end + end + record(found, 'config.table_auto_fmt_autocmd', + found and '' or 'attach did not register the InsertLeave autocmd when enabled') + cfg.options.table_auto_fmt = false + vim.cmd('bwipeout!') + end + -- ===== Lists ===== run('list.toggle_via_C-Space', { diff --git a/development/tests/test-keymaps.sh b/development/tests/test-keymaps.sh index 72b115a..f6ed2c0 100755 --- a/development/tests/test-keymaps.sh +++ b/development/tests/test-keymaps.sh @@ -39,8 +39,14 @@ cat > "$INIT" <` joins a spaced name and an empty arg reaches + the prompt. Both handlers already prompt on empty. Covered by + `cmd.VimwikiGoto_accepts_multiword` (`test-keymaps-vim.vim`). +- [ ] **`VimwikiRenameFile` lacks `-nargs=?`** _(new, 2026-06-03 re-audit)_ — + upstream is `-nargs=? -complete=…file`; nuwiki's defs are bare, so + `:VimwikiRenameFile foo` raises E488. Subsumed by the existing "rename + delegates to the LSP rename request, takes no filename arg" divergence (the + `-complete=` item below) — adding `-nargs=?` (accepted-ignored) would restore + signature parity if desired. Low priority. - [ ] `VimwikiVar` — config-var get/set introspection. _Fix:_ `plugin/nuwiki.vim`. - [x] **`VimwikiShowVersion`** _(fixed 2026-06-03)_ — added global `VimwikiShowVersion`/`NuwikiShowVersion` (both clients) echoing @@ -400,6 +415,42 @@ fix site. `cmd.VimwikiSplitLink_accepts_args` (`test-keymaps-vim.vim`, no E488). ### Config +- [x] **`autowriteall`** _(new, 2026-06-03 re-audit; fixed same day)_ — upstream + global (`vars.vim:136`, default **`1`/ON**): while a wiki buffer is current, + mirror Vim's global `'autowriteall'` (auto-save a modified buffer on page + switch / `:make`), restoring the prior value on leave (upstream + `plugin/vimwiki.vim:165-166,39`). nuwiki had no equivalent → out-of-box + behavioral divergence. _Fix:_ client-side, both clients — Neovim + `lua/nuwiki/ftplugin.lua` (`setup_autowriteall`, BufEnter/BufLeave save+set/ + restore) gated by the `autowriteall` setup option (default true); Vim + `ftplugin/vimwiki.vim` (`NuwikiAutoWriteAll` augroup) gated by + `g:nuwiki_autowriteall` (default 1). Covered by `config.autowriteall_applied` + in both harnesses. +- [x] **`table_auto_fmt`** _(new, 2026-06-03 re-audit; fixed same day)_ — + upstream global (`vars.vim:183`, default **`1`/ON**): re-format the table under + the cursor on `InsertLeave` (upstream `plugin/vimwiki.vim:330`). nuwiki had no + equivalent (tables formatted only via `gqq`/`gww`). _Fix:_ client-side + `InsertLeave` autocmd, gated by config — Neovim `table_auto_fmt` setup option + (default true, `ftplugin.lua` `setup_table_auto_fmt`); Vim + `g:nuwiki_table_auto_fmt` (default 1, `NuwikiTableAutoFmt` augroup). Both guard + on the cursor line containing `|` before the (async LSP) `table_align`, so + non-table edits don't round-trip. Covered by `config.table_auto_fmt_autocmd` + in both harnesses. _(Divergence: nuwiki's `table_align` is an async server + edit, vs upstream's synchronous format — the result lands a beat after Esc.)_ +- [ ] **`table_reduce_last_col`** _(new, 2026-06-03 re-audit)_ — upstream global + (`vars.vim:184`, default `0`): don't expand the last column separator to fill + the cell. nuwiki absent. Low impact (off by default). _Fix:_ thread a flag into + the table-format routine. +- [ ] **`user_htmls`** _(new, 2026-06-03 re-audit)_ — upstream global + (`vars.vim:191`, default `''`): comma-separated HTML files with no wiki source + that `:VimwikiAll2HTML` must not delete. nuwiki absent — only relevant if + nuwiki's all-to-HTML prunes orphan HTML (it may not, in which case this is moot + and worth a one-line divergence note rather than code). +- [ ] **`hl_headers` / `hl_cb_checked`** _(new, 2026-06-03 re-audit)_ — upstream + globals (`vars.vim:158`/`157`, both default `0`): per-level header highlight / + checked-checkbox line highlight. nuwiki absent. Borderline — either implement + via highlight groups/semantic tokens, or fold into the `conceal*`/`maxhi` + highlighting-divergence family so future audits stop flagging them. - [x] **`list_margin` — buffer-side parity + markdown default** _(new, 2026-06-02 re-audit; fixed 2026-06-02)_ — upstream (`vars.vim:516`, doc `vimwiki.txt:2667`): left-margin **width in spaces for buffer-side generated @@ -449,7 +500,9 @@ fix site. - [ ] `dir_link` — index file to open when following a directory link. - [ ] `auto_chdir` — `:cd` into wiki root on open (client-side). - [ ] `bullet_types` / `cycle_bullets` — custom bullet glyphs + wrap-around. -- [ ] `commentstring` (`'%%%s'`) — comment toggling/text-objects. +- [ ] `commentstring` (`'%%%s'`) — comment toggling/text-objects. _(2026-06-03 + re-audit: also a value mismatch — nuwiki hardcodes `%% %s` (with a space) in + `ftplugin/vimwiki.vim:18` vs upstream's no-space `%%%s`; align when picked up.)_ - [ ] `color_tag_template` — `color_dic` present; template regex missing. Related divergence _(2026-05-31 config re-audit)_: nuwiki's `color_dic` defaults to **empty** while upstream ships a populated palette @@ -608,3 +661,13 @@ audits don't re-flag them. of the documented "generated-content is vimwiki-only" divergence. All five P1-blocking sections remain clear; only niche P3 items (and the deferred markdown work) are left. +- Re-audited 2026-06-03 (fifth pass — commands / config / mappings, three + parallel agents) against vimwiki `a54a300` (still no upstream commits since + 2026-04-30). **Mappings: clean** again (confirmed `gLH/gLL/gLR` correct; no new + gaps, no regressions). **Commands:** one real bug — `VimwikiGoto`/`NuwikiGoto` + were `-nargs=1` (E471/E488 + unreachable prompt), fixed same day; plus + `VimwikiRenameFile`'s missing `-nargs=?` logged (subsumed by the LSP-rename + divergence). **Config:** five new items — `autowriteall` and `table_auto_fmt` + (both ON upstream → out-of-box divergences, implemented same day), + `table_reduce_last_col`, `user_htmls`, `hl_headers`/`hl_cb_checked` logged; and + a `commentstring` value-mismatch note. No previously-closed item regressed. diff --git a/doc/nuwiki.txt b/doc/nuwiki.txt index 7ea17a3..df7a0fb 100644 --- a/doc/nuwiki.txt +++ b/doc/nuwiki.txt @@ -306,6 +306,20 @@ Vim-specific globals ~ `g:nuwiki_no_folding` 0 When 1, the Vim path skips `foldexpr` / `foldmethod` setup. + *g:nuwiki_autowriteall* +`g:nuwiki_autowriteall` 1 + When 1 (default), Vim's global `'autowriteall'` is set while a wiki + buffer is current and restored on leave, so a modified buffer is + auto-saved on page switch / `:make`. Mirrors vimwiki's `autowriteall` + and the Neovim `autowriteall` setup option. Set to 0 to leave + `'autowriteall'` untouched. + + *g:nuwiki_table_auto_fmt* +`g:nuwiki_table_auto_fmt` 1 + When 1 (default), the table under the cursor is re-aligned on + |InsertLeave|. Mirrors vimwiki's `table_auto_fmt` and the Neovim + `table_auto_fmt` setup option. Set to 0 to disable. + *g:nuwiki_mouse_mappings* `g:nuwiki_mouse_mappings` 0 When 1, the Vim path registers mouse keymaps (double-click follows, diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index a0aa09b..36a9b7c 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -37,6 +37,33 @@ augroup END call nuwiki#colors#refresh() let b:undo_ftplugin .= ' | execute "autocmd! NuwikiColorConceal * "' +" vimwiki `autowriteall` / `table_auto_fmt` (Vim path; Neovim wires both via +" lua/nuwiki/ftplugin.lua). autowriteall mirrors the option into Vim's global +" &autowriteall while a wiki buffer is current (auto-save on switch/make), +" restoring the prior value on leave. table_auto_fmt re-aligns the table under +" the cursor on InsertLeave. Disable with g:nuwiki_autowriteall / +" g:nuwiki_table_auto_fmt = 0. +if !has('nvim') + if get(g:, 'nuwiki_autowriteall', 1) + augroup NuwikiAutoWriteAll + autocmd! * + autocmd BufEnter let s:nuwiki_awa_saved = &autowriteall | let &autowriteall = 1 + autocmd BufLeave let &autowriteall = get(s:, 'nuwiki_awa_saved', &autowriteall) + augroup END + " FileType fires after the initial BufEnter, so apply once now too. + let s:nuwiki_awa_saved = &autowriteall + let &autowriteall = 1 + let b:undo_ftplugin .= ' | execute "autocmd! NuwikiAutoWriteAll * "' + endif + if get(g:, 'nuwiki_table_auto_fmt', 1) + augroup NuwikiTableAutoFmt + autocmd! * + autocmd InsertLeave if getline('.') =~# '|' | call nuwiki#commands#table_align() | endif + augroup END + let b:undo_ftplugin .= ' | execute "autocmd! NuwikiTableAutoFmt * "' + endif +endif + if !has('nvim') " ===== Plain Vim path ===== " @@ -69,7 +96,7 @@ if !has('nvim') command! -buffer VimwikiBaddLink call nuwiki#commands#badd_link() command! -buffer -nargs=* VimwikiSearch lvimgrep // ** command! -buffer -nargs=* VWS lvimgrep // ** - command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages VimwikiGoto call nuwiki#commands#wiki_goto_page() + command! -buffer -nargs=* -complete=customlist,nuwiki#complete#pages VimwikiGoto call nuwiki#commands#wiki_goto_page() command! -buffer VimwikiDeleteFile call nuwiki#commands#delete_file() command! -buffer VimwikiDeleteLink call nuwiki#commands#delete_file() @@ -152,7 +179,7 @@ if !has('nvim') command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiSearchTags call nuwiki#commands#tags_search() command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiGenerateTagLinks call nuwiki#commands#tags_generate_links() command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiGenerateTags call nuwiki#commands#tags_generate_links() - command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages NuwikiGoto call nuwiki#commands#wiki_goto_page() + command! -buffer -nargs=* -complete=customlist,nuwiki#complete#pages NuwikiGoto call nuwiki#commands#wiki_goto_page() " Canonical :Nuwiki* names that mirror the documented surface. " The older :Nuwiki* spellings above stay defined for back-compat. @@ -417,7 +444,7 @@ command! -buffer VimwikiTabDropLink lua require('nuwiki.commands').follow command! -buffer VimwikiNextLink lua require('nuwiki.commands').link_next() command! -buffer VimwikiPrevLink lua require('nuwiki.commands').link_prev() command! -buffer VimwikiBaddLink lua require('nuwiki.commands').badd_link() -command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages VimwikiGoto lua require('nuwiki.commands').wiki_goto_page() +command! -buffer -nargs=* -complete=customlist,nuwiki#complete#pages VimwikiGoto lua require('nuwiki.commands').wiki_goto_page() command! -buffer VimwikiBacklinks lua vim.lsp.buf.references() command! -buffer VWB lua vim.lsp.buf.references() command! -buffer -nargs=* VimwikiSearch lvimgrep // ** @@ -501,7 +528,7 @@ command! -buffer -bang NuwikiRebuildTags lua require('nuwiki.comma command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiSearchTags lua require('nuwiki.commands').tags_search() command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links() command! -buffer -nargs=? -complete=customlist,nuwiki#complete#tags NuwikiGenerateTags lua require('nuwiki.commands').tags_generate_links() -command! -buffer -nargs=1 -complete=customlist,nuwiki#complete#pages NuwikiGoto lua require('nuwiki.commands').wiki_goto_page() +command! -buffer -nargs=* -complete=customlist,nuwiki#complete#pages NuwikiGoto lua require('nuwiki.commands').wiki_goto_page() " Canonical :Nuwiki* names that mirror the documented surface. " The older :Nuwiki* spellings above stay defined for back-compat. diff --git a/lua/nuwiki/config.lua b/lua/nuwiki/config.lua index 59de8fe..8b1108e 100644 --- a/lua/nuwiki/config.lua +++ b/lua/nuwiki/config.lua @@ -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' diff --git a/lua/nuwiki/ftplugin.lua b/lua/nuwiki/ftplugin.lua index d48a1c6..3970e01 100644 --- a/lua/nuwiki/ftplugin.lua +++ b/lua/nuwiki/ftplugin.lua @@ -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