test(calendar): add Vim + Neovim integration harnesses
CI / cargo fmt --check (push) Successful in 26s
CI / cargo clippy (push) Successful in 27s
CI / cargo test (push) Successful in 31s
CI / editor keymaps (push) Successful in 1m30s

Add headless harnesses covering the calendar-vim integration, wired into
CI alongside the existing keymap/config suites:

- test-calendar-vim.sh/.vim (+ -optout.vim): pure-VimL diary hooks
  (calendar_sign markers, calendar_action path resolution from wiki root,
  calendar window close), plugin/nuwiki.vim hook auto-wiring that
  overrides calendar-vim's defaults, and opt-out via g:nuwiki_use_calendar
  and g:nuwiki_no_calendar. Uses a stub calendar-vim on the runtimepath.
- test-calendar.sh/.lua: Neovim setup() wiring + window-close under the
  real window API, and opt-out via use_calendar = false.

Fixes surfaced by the suite:
- diary.vim: new diary entries set filetype 'vimwiki' (was the raw
  extension, e.g. 'wiki'); the stray FileType autocmd also blocked the
  calendar window from closing.
- init.lua: drop the redundant Neovim FileType autocmd (plugin/nuwiki.vim
  already wires both editors) and translate use_calendar=false into
  g:nuwiki_no_calendar so the opt-out actually disables wiring.
This commit is contained in:
2026-05-31 21:45:50 -03:00
parent 7a3e11cfeb
commit 87ba4c1764
9 changed files with 475 additions and 27 deletions
+5 -20
View File
@@ -85,26 +85,11 @@ function M.setup(opts)
vim.filetype.add({ extension = extensions })
end
-- Auto-detect calendar-vim and wire hooks when the first vimwiki buffer loads.
-- On by default; disable with use_calendar = false or g:nuwiki_no_calendar.
if config.options.use_calendar ~= false and not config.options.no_calendar then
vim.api.nvim_create_autocmd('FileType', {
pattern = 'vimwiki',
callback = function()
if vim.fn.exists('*calendar#open') == 1 or vim.fn.exists(':Calendar') == 2 then
-- Overwrite calendar-vim's own defaults (which write to ~/diary)
-- but respect a user-set custom hook.
local act = vim.g.calendar_action
if not act or act == '' or act == 'calendar#diary' then
vim.g.calendar_action = 'vimwiki#diary#calendar_action'
end
local sign = vim.g.calendar_sign
if not sign or sign == '' or sign == 'calendar#sign' then
vim.g.calendar_sign = 'vimwiki#diary#calendar_sign'
end
end
end,
})
-- Calendar-vim wiring lives in plugin/nuwiki.vim's FileType autocmd, which
-- runs for both Vim and Neovim. Translate the Lua-side opt-out into the
-- g: flag that autocmd reads so `use_calendar = false` fully disables it.
if config.options.use_calendar == false then
vim.g.nuwiki_no_calendar = 1
end
lsp.register()