feat(calendar): diary into the current wiki, not always the first
CI / cargo fmt --check (push) Successful in 46s
CI / cargo clippy (push) Successful in 51s
CI / cargo test (push) Successful in 58s
CI / editor keymaps (push) Successful in 1m29s

The VimL calendar-vim callbacks (nuwiki#diary#calendar_action /
calendar_sign) hardcoded wiki 0, so opening the calendar while editing
ifood_wiki still created/marked diary entries under the first wiki. (The
LSP-driven diary commands already follow the current buffer via its URI;
this brings the calendar in line.)

Track the wiki of the active buffer (nuwiki#diary#track_wiki, driven by
FileType/BufEnter autocmds in plugin/nuwiki.vim) and resolve the calendar
diary path against it, falling back to the first wiki. Verified the
calendar marker/open switch between wikis as you move between their
buffers. test-calendar-vim gains 4 multi-wiki tracking checks (16).
All keymap/config/calendar harnesses green on both clients.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-06 02:07:11 +00:00
parent 0d1a73a3ba
commit 3e8c534859
3 changed files with 54 additions and 4 deletions
+18
View File
@@ -89,6 +89,24 @@ call s:record(winnr('$') == s:wins_before - 1, 'action.window_count_decremented'
call s:record(&filetype ==# 'vimwiki', 'action.sets_filetype',
\ 'filetype=' . &filetype)
" ===== calendar follows the current wiki (multi-wiki) =====
" Two wikis, each with its own diary entry. track_wiki() (driven by the
" BufEnter autocmd in real use) switches which wiki the calendar reads.
let s:wA = tempname() | call mkdir(s:wA . '/diary', 'p')
let s:wB = tempname() | call mkdir(s:wB . '/diary', 'p')
call writefile(['a'], s:wA . '/diary/2026-06-02.wiki')
call writefile(['b'], s:wB . '/diary/2026-06-10.wiki')
let g:nuwiki_wikis = [{'root': s:wA}, {'root': s:wB}]
call nuwiki#diary#track_wiki(s:wA . '/index.wiki')
call s:record(nuwiki#diary#calendar_sign(2, 6, 2026) ==# '*', 'track.wikiA_own_entry', '')
call s:record(nuwiki#diary#calendar_sign(10, 6, 2026) ==# '', 'track.wikiA_not_wikiB_entry', '')
call nuwiki#diary#track_wiki(s:wB . '/index.wiki')
call s:record(nuwiki#diary#calendar_sign(10, 6, 2026) ==# '*', 'track.wikiB_own_entry', '')
call s:record(nuwiki#diary#calendar_sign(2, 6, 2026) ==# '', 'track.wikiB_not_wikiA_entry', '')
unlet g:nuwiki_wikis
" ===== Wrap up =====
call add(s:results, '')