feat(config): on-save autoregen family — links/tags/diary-index (P2)
CI / cargo fmt --check (push) Successful in 17s
CI / cargo clippy (push) Successful in 38s
CI / cargo test (push) Successful in 41s
CI / editor keymaps (push) Successful in 1m25s

Added per-wiki auto_generate_links, auto_generate_tags, auto_diary_index
(default false, like upstream), wired into the did_save hook mirroring
auto_toc:

- auto_generate_links / auto_generate_tags rebuild the Generated Links /
  Generated Tags section ONLY when it already exists (new
  links_rebuild_edit / tag_links_rebuild_edit, like toc_rebuild_edit) — never
  inserts one into a page that lacks it.
- auto_diary_index regenerates the diary index page when a dated diary entry
  (not the index itself) is saved, via diary_generate_index_edit (handles the
  index file open / on-disk / absent).

auto_tags is recorded as an intentional divergence: nuwiki re-indexes tags on
every change, so the tag metadata is always fresh (no on-disk file to update).

Tests: links_rebuild_edit_only_acts_when_section_present,
tag_links_rebuild_edit_only_acts_when_index_present, config round-trip +
defaults. README/doc/lua comment updated. fmt/clippy clean; 0 Rust failures.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 18:55:51 +00:00
parent 3fd04b0efa
commit 09b5a2bd46
10 changed files with 255 additions and 3 deletions
+6
View File
@@ -231,6 +231,9 @@ require('nuwiki').setup({
css_name = 'style.css',
auto_export = false, -- export on save
auto_toc = false, -- auto-refresh TOC on save
auto_generate_links = false, -- regen Generated Links on save
auto_generate_tags = false, -- regen Generated Tags index on save
auto_diary_index = false, -- regen diary index on diary-entry save
toc_header = 'Contents', -- :VimwikiTOC caption (+ toc_header_level = 1)
links_header = 'Generated Links',
tags_header = 'Generated Tags',
@@ -336,6 +339,9 @@ Each is a boolean. All default to `true` except `mouse`.
| `list_margin` | int | `-1` | `-1` (auto) or `≥ 0` |
| `links_space_char` | string | `' '` | char that replaces spaces in synthesised link paths |
| `auto_toc` | bool | `false` | `true` \| `false` |
| `auto_generate_links` | bool | `false` | regenerate an existing Generated Links section on save |
| `auto_generate_tags` | bool | `false` | regenerate an existing Generated Tags index on save |
| `auto_diary_index` | bool | `false` | regenerate the diary index when a diary entry is saved |
| `toc_header` / `toc_header_level` | string / int | `'Contents'` / `1` | `:VimwikiTOC` caption + heading level |
| `links_header` / `links_header_level` | string / int | `'Generated Links'` / `1` | `:VimwikiGenerateLinks` caption + level |
| `tags_header` / `tags_header_level` | string / int | `'Generated Tags'` / `1` | `:VimwikiGenerateTagLinks` index caption + level |