feat(calendar): integrate calendar-vim with wiki diary paths
CI / cargo fmt --check (push) Successful in 34s
CI / cargo clippy (push) Successful in 43s
CI / cargo test (push) Successful in 41s
CI / editor keymaps (push) Successful in 1m29s

Wire g:calendar_action/g:calendar_sign to nuwiki diary hooks that
resolve diary paths from the wiki root config instead of calendar-vim's
default ~/diary. Auto-detected on FileType vimwiki when calendar-vim is
present; opt out with g:nuwiki_use_calendar=0 or g:nuwiki_no_calendar.

- autoload/nuwiki/diary.vim: calendar_action/calendar_sign using wiki cfg;
  open diary in the previous window and close the calendar window after.
- autoload/vimwiki/diary.vim: vimwiki# aliases for drop-in compatibility.
- plugin/nuwiki.vim + lua/nuwiki/init.lua: auto-wire hooks, overwriting
  calendar-vim's defaults while respecting user-set custom hooks.
- lua/nuwiki/config.lua: add use_calendar option (on by default).
- development/start-*.sh + _common.sh: clone calendar-vim, fix vimrc var
  expansion, pass wiki root to the Vim/Neovim clients.
This commit is contained in:
2026-05-31 21:34:41 -03:00
parent 39692ba99f
commit 7a3e11cfeb
9 changed files with 211 additions and 36 deletions
+6
View File
@@ -56,6 +56,12 @@ M.defaults = {
diagnostic = {
link_severity = 'warn',
},
-- Calendar-vim integration. On by default — set to `false` to opt out.
-- When on, nuwiki detects calendar-vim on the runtimepath and wires
-- `g:calendar_action` / `g:calendar_sign` automatically.
-- Also respects `g:nuwiki_no_calendar` set before setup() to disable.
use_calendar = true,
}
M.options = vim.deepcopy(M.defaults)
+22
View File
@@ -85,6 +85,28 @@ 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,
})
end
lsp.register()
_setup_global_mappings()
_setup_global_commands()