feat(diary): restore diary_start_week_day via configurable weekly naming
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:
@@ -219,6 +219,8 @@ require('nuwiki').setup({
|
||||
diary_rel_path = 'diary',
|
||||
diary_index = 'diary',
|
||||
diary_frequency = 'daily', -- 'daily' | 'weekly' | 'monthly' | 'yearly'
|
||||
diary_weekly_style = 'iso', -- 'iso' (YYYY-Www) | 'date' (week-start YYYY-MM-DD, vimwiki)
|
||||
diary_start_week_day = 'monday', -- week start for diary_weekly_style='date'
|
||||
diary_sort = 'desc', -- 'desc' | 'asc'
|
||||
diary_header = 'Diary',
|
||||
-- HTML export
|
||||
@@ -319,7 +321,9 @@ Each is a boolean. All default to `true` except `mouse`.
|
||||
| `diary_rel_path` | string | `'diary'` | path relative to `root` |
|
||||
| `diary_index` | string | `'diary'` | diary index page stem |
|
||||
| `diary_frequency` | string | `'daily'` | `'daily'` \| `'weekly'` \| `'monthly'` \| `'yearly'` |
|
||||
| `diary_caption_level` | int | `1` | `1`–`6` (level of the index caption) |
|
||||
| `diary_weekly_style` | string | `'iso'` | `'iso'` (`YYYY-Www`) \| `'date'`/`'vimwiki'` (week-start `YYYY-MM-DD`). Weekly only |
|
||||
| `diary_start_week_day` | string | `'monday'` | `'monday'`–`'sunday'`; week start when `diary_weekly_style = 'date'` |
|
||||
| `diary_caption_level` | int | `0` | `0`–`6` (level of the index caption) |
|
||||
| `diary_sort` | string | `'desc'` | `'desc'` \| `'asc'` |
|
||||
| `diary_header` | string | `'Diary'` | any heading text |
|
||||
| `listsyms` | string | `' .oOX'` | checkbox progression chars |
|
||||
|
||||
Reference in New Issue
Block a user