feat(diary): restore diary_start_week_day via configurable weekly naming
CI / cargo fmt --check (push) Successful in 29s
CI / cargo clippy (push) Successful in 34s
CI / cargo test (push) Successful in 31s
CI / editor keymaps (push) Successful in 1m34s

c63ec67 dropped diary_start_week_day, hardwiring the weekly diary to ISO
(Monday) weeks. Upstream vimwiki instead names a weekly note by the
week-start day's date (YYYY-MM-DD) and honours diary_start_week_day. Rather
than force one scheme, make it a per-wiki choice so migrators keep upstream
behaviour while existing nuwiki weekly files keep working:

- New per-wiki key `diary_weekly_style`: `iso` (default — `YYYY-Www`,
  Monday-based, nuwiki's original) or `date`/`vimwiki` (`YYYY-MM-DD` of the
  week-start day, upstream parity).
- Restored per-wiki key `diary_start_week_day` (`monday`..`sunday`, default
  monday); applies only in `date` mode.

Implementation:
- nuwiki-core::date gains WeeklyStyle, WeekStart, and DiaryCalendar (owns
  today/next/prev — date-mode snaps to the week-start and steps ±7 days;
  iso/daily/monthly/yearly defer to the existing DiaryPeriod logic).
- WikiConfig gains the two fields (+ defaults, RawWiki, From) and a
  diary_calendar() builder; commands.rs diary_open_relative and the
  next/prev pivot use it.

Defaults preserve current behaviour (iso/monday), so no breaking change.
Tests: DiaryCalendar cases in nuwiki-core/tests/diary.rs (snap, ±7, sunday
start, iso delegation, daily) + config round-trip in
nuwiki-lsp/tests/index_and_config.rs. README + doc/nuwiki.txt + lua config
comment updated. fmt + clippy clean; all crate tests + config-parity green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 17:06:09 +00:00
parent 28d5caf581
commit b8586537f8
9 changed files with 318 additions and 14 deletions
+12 -1
View File
@@ -182,7 +182,11 @@ match upstream vimwiki.
`diary_rel_path` `'diary'`
`diary_index` `'diary'` — stem of the diary index page.
`diary_frequency` `'daily'` | `'weekly'` | `'monthly'` | `'yearly'`
`diary_caption_level` `1`
`diary_weekly_style` `'iso'` (YYYY-Www) | `'date'`/`'vimwiki'` (week-start
YYYY-MM-DD). Weekly diaries only.
`diary_start_week_day` `'monday'`..`'sunday'`; week start used when
`diary_weekly_style = 'date'`.
`diary_caption_level` `0`
`diary_sort` `'desc'` | `'asc'`
`diary_header` `'Diary'`
`html_path` Path for `:Vimwiki2HTML` output.
@@ -582,6 +586,13 @@ The `diary_frequency` per-wiki option controls the cadence:
monthly YYYY-MM e.g. `2026-05.wiki`
yearly YYYY e.g. `2026.wiki`
For weekly diaries, `diary_weekly_style` chooses the file name: the default
`'iso'` uses the ISO-week label above (always Monday-based); `'date'` (a.k.a.
`'vimwiki'`) names the file after the week-start day's date — e.g. with
`diary_start_week_day = 'monday'`, the week of 2026-05-27 is `2026-05-25.wiki`
— matching upstream vimwiki. `diary_start_week_day` (`'monday'`..`'sunday'`)
only applies in `'date'` mode.
`:NuwikiMakeDiaryNote` opens the entry for the current period at the
configured cadence; the yesterday / tomorrow commands step back and
forward by one period. `<C-Down>` / `<C-Up>` walk between indexed