" development/tests/test-calendar-vim.vim — driven by development/tests/test-calendar-vim.sh. " " Pure-VimL regression suite for the calendar-vim integration. The diary " hooks (nuwiki#diary#calendar_action / nuwiki#diary#calendar_sign) are " implemented entirely in VimL and shared verbatim by the Vim and Neovim " clients, so this harness is the canonical coverage for them. The Vim " plugin-side hook wiring (plugin/nuwiki.vim's FileType autocmd) is also " asserted here; the Neovim setup() wiring has its own harness in " development/tests/test-calendar.lua. " " A stub calendar-vim is placed on the runtimepath by the shell wrapper so " :Calendar exists and g:calendar_action/g:calendar_sign already hold " calendar-vim's own defaults ('calendar#diary'/'calendar#sign') — exactly " the state nuwiki must detect and override. let s:results = [] let s:pass = 0 let s:fail = 0 let s:out = $NUWIKI_CALENDAR_RESULTS function! s:record(ok, name, detail) abort let l:line = (a:ok ? 'PASS' : 'FAIL') . ' ' . a:name if a:detail !=# '' let l:line .= ' — ' . a:detail endif call add(s:results, l:line) if a:ok let s:pass += 1 else let s:fail += 1 endif endfunction let s:wiki_root = $NUWIKI_CALENDAR_WIKI " ===== Hook wiring: nuwiki overrides calendar-vim's defaults ===== " The stub set g:calendar_action='calendar#diary' / g:calendar_sign='calendar#sign' " at load. Opening this .wiki buffer fired plugin/nuwiki.vim's FileType autocmd, " which must have rewired both to the nuwiki delegators. call s:record(&filetype ==# 'vimwiki', 'ftplugin.attached', \ &filetype ==# 'vimwiki' ? '' : 'filetype=' . &filetype) call s:record(get(g:, 'calendar_action', '') ==# 'vimwiki#diary#calendar_action', \ 'hook.action_wired', 'g:calendar_action=' . get(g:, 'calendar_action', '')) call s:record(get(g:, 'calendar_sign', '') ==# 'vimwiki#diary#calendar_sign', \ 'hook.sign_wired', 'g:calendar_sign=' . get(g:, 'calendar_sign', '')) " ===== calendar_sign: marker reflects diary-file existence ===== " The shell seeded a diary entry for 2026-05-30 and left 2026-05-31 absent. call s:record(nuwiki#diary#calendar_sign(30, 5, 2026) ==# '*', \ 'sign.existing_date_marked', \ 'got ' . string(nuwiki#diary#calendar_sign(30, 5, 2026))) call s:record(nuwiki#diary#calendar_sign(31, 5, 2026) ==# '', \ 'sign.absent_date_unmarked', \ 'got ' . string(nuwiki#diary#calendar_sign(31, 5, 2026))) " The vimwiki# alias must return the identical result. call s:record(vimwiki#diary#calendar_sign(30, 5, 2026) ==# '*', \ 'sign.alias_matches', '') " ===== calendar_action: opens WIKI_ROOT/diary/.wiki, not ~/diary ===== " Set up two windows so the "previous window" branch runs and we can assert " the calendar window is closed afterwards. " Window A: the seed wiki (already current). Open a fresh window to stand in " for the calendar, then invoke the action from it. new file [stub-calendar] let s:cal_winid = win_getid() let s:wins_before = winnr('$') call nuwiki#diary#calendar_action(31, 5, 2026, 0, '') let s:opened = expand('%:p') let s:want = s:wiki_root . '/diary/2026-05-31.wiki' call s:record(s:opened ==# s:want, 'action.opens_wiki_diary_path', \ 'opened=' . s:opened) call s:record(s:opened !~# '/diary/2026-05-31.wiki$' ? 0 : 1, \ 'action.path_has_date_filename', 'opened=' . s:opened) call s:record(s:opened !~# expand('~') . '/diary', \ 'action.not_home_diary', 'opened=' . s:opened) " The calendar window must be closed once the diary is open. call s:record(win_id2win(s:cal_winid) == 0, 'action.closes_calendar_window', \ 'cal still at win ' . win_id2win(s:cal_winid)) call s:record(winnr('$') == s:wins_before - 1, 'action.window_count_decremented', \ 'before=' . s:wins_before . ' after=' . winnr('$')) " ===== calendar_action sets the wiki filetype on a new entry ===== call s:record(&filetype ==# 'vimwiki', 'action.sets_filetype', \ 'filetype=' . &filetype) " ===== Wrap up ===== call add(s:results, '') call add(s:results, printf('SUMMARY: %d passed, %d failed', s:pass, s:fail)) call writefile(s:results, s:out) execute (s:fail == 0 ? 'qall!' : 'cquit!')