feat(config): vimwiki drop-in config + global per-wiki defaults
Two related config-ergonomics features for vimwiki migrants, sharing the
same scalar-global machinery.
1. Upstream g:vimwiki_* drop-in (Vim client). When nuwiki isn't configured
natively, the Vim client reads g:vimwiki_list + g:vimwiki_* globals and
translates them into nuwiki's schema: per-wiki path->root,
path_html->html_path, template_*, css_name, auto_export/auto_toc,
syntax, ext->file_extension, index, diary_*, name. g:nuwiki_* always
wins. Lets a vimwiki user drop in nuwiki without rewriting config.
2. Global per-wiki defaults (both clients). A display/generation setting
given once at the top level — g:nuwiki_<key> / setup({<key>=…}) /
g:vimwiki_<key> — is folded into every wiki as a default; a per-wiki
value overrides it (vimwiki's model). Covers toc_header(_level),
toc_link_format, links_header(_level), tags_header(_level),
html_header_numbering(_sym), links_space_char, list_margin, listsyms,
listsym_rejected, and the auto_* toggles. Only values the user
explicitly set fold — built-in defaults don't (added config.user
tracking on the Lua side so a default toc_header_level=1 isn't pushed
onto every wiki). User config tables are never mutated.
Both clients kept in lock-step (config-parity golden enforces identical
payloads). New harnesses test-vimwiki-compat-vim (18) and
test-global-shorthand (8), wired into CI. Server test
vimwiki_compat_payload_sets_toc_level_per_wiki. Docs in README +
known-issues.md (drop-in is currently Vim-only). Rust 573 passed, clippy
clean, all harnesses green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -674,3 +674,20 @@ fn legacy_single_wiki_shape_picks_up_defaults() {
|
||||
assert_eq!(cfg.wikis[0].index, "index");
|
||||
assert_eq!(cfg.wikis[0].diary_frequency, "daily");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vimwiki_compat_payload_sets_toc_level_per_wiki() {
|
||||
// The exact shape the Vim client emits when translating g:vimwiki_list +
|
||||
// g:vimwiki_toc_header_level=2 (drop-in vimwiki compat).
|
||||
let cfg = config_from_json(json!({
|
||||
"wiki_root": "~/vimwiki",
|
||||
"wikis": [
|
||||
{ "root": "/tmp/personal", "toc_header_level": 2, "html_header_numbering": 2 },
|
||||
{ "root": "/tmp/ifood", "toc_header_level": 2 },
|
||||
],
|
||||
}));
|
||||
assert_eq!(cfg.wikis.len(), 2);
|
||||
assert_eq!(cfg.wikis[0].toc_header_level, 2);
|
||||
assert_eq!(cfg.wikis[0].html.html_header_numbering, 2);
|
||||
assert_eq!(cfg.wikis[1].toc_header_level, 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user