feat(config): P3 config batch — group 1 (clean config + plumbing)

Config plumbing for the whole config batch (HtmlConfig + WikiConfig fields,
RawWiki deserialization, From/defaults) plus these behaviors:

- rss_name / rss_max_items: HtmlConfig fields (wired into write_rss in the RSS
  group).
- toc_link_format: build_toc_text emits [[#anchor]] (no description) for 1,
  [[#anchor|title]] for 0.
- generated_links_caption: build_links_text emits [[page|FirstHeading]] from a
  page->heading map (ops::page_captions) when enabled.
- table_reduce_last_col: column_widths clamps the last column to width 1 when
  set; threaded through table_align_edit/table_move_column_edit + commands.
- color_dic now ships a populated default palette (red/green/blue/...).
- commentstring aligned to upstream's no-space `%%%s`.
- auto_chdir (default off): :lcd into the owning wiki root on buffer enter;
  both clients (ftplugin.lua setup_auto_chdir + Vim NuwikiAutoChdir augroup),
  with config.wiki_root_for / nuwiki#commands#wiki_root_for resolvers.

Also seeded HtmlConfig fields for later groups (valid_html_tags,
list/text_ignore_newline, emoji_enable, user_htmls, color_tag_template) and
WikiConfig (create_link, dir_link, bullet_types, cycle_bullets).

Tests: toc_link_format, generated_links_caption, table_reduce_last_col,
config defaults + JSON round-trip for every new key. Full rust suite +
both keymap harnesses green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 12:04:36 +00:00
parent 03005d0931
commit b2f2fc88bd
11 changed files with 522 additions and 48 deletions
+22
View File
@@ -168,6 +168,28 @@ endfunction
" from the server, so the picker works from any buffer before a wiki file is
" ever opened — opening the chosen index then auto-starts the LSP via the
" FileType autocmd. Plain Vim has no `vim.ui.select`, so use `inputlist()`.
" Absolute root (with trailing slash) of the wiki that owns `a:file`, or the
" first configured wiki as a fallback. Used by auto_chdir + search scoping.
function! nuwiki#commands#wiki_root_for(file) abort
for l:w in nuwiki#commands#wiki_list()
let l:wroot = fnamemodify(expand(l:w.root), ':p')
if a:file[: len(l:wroot) - 1] ==# l:wroot
return l:wroot
endif
endfor
let l:wikis = nuwiki#commands#wiki_list()
return empty(l:wikis) ? '' : fnamemodify(expand(l:wikis[0].root), ':p')
endfunction
" :NuwikiAutoChdir hook — `:lcd` into the owning wiki's root (vimwiki
" `auto_chdir`). Wired from a buffer-local autocmd in the ftplugin.
function! nuwiki#commands#auto_chdir() abort
let l:root = nuwiki#commands#wiki_root_for(expand('%:p'))
if l:root !=# ''
execute 'lcd ' . fnameescape(l:root)
endif
endfunction
" :VimwikiShowVersion / :NuwikiShowVersion — echo the nuwiki version and the
" host editor, mirroring upstream's version banner.
function! nuwiki#commands#show_version() abort