feat(calendar): integrate calendar-vim with wiki diary paths
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:
@@ -27,6 +27,30 @@ else
|
||||
command! -nargs=0 NuwikiInstall execute 'source' fnameescape(s:plugin_root . '/scripts/download_bin.vim')
|
||||
endif
|
||||
|
||||
" Calendar-Vim Integration — auto-detect when calendar-vim is loaded.
|
||||
augroup nuwiki_calendar_detect
|
||||
autocmd!
|
||||
autocmd FileType vimwiki call s:nuwiki_setup_calendar()
|
||||
augroup END
|
||||
function! s:nuwiki_setup_calendar() abort
|
||||
if !get(g:, 'nuwiki_use_calendar', 1) || get(g:, 'nuwiki_no_calendar', 0)
|
||||
return
|
||||
endif
|
||||
if exists('*calendar#open') || exists(':Calendar') == 2
|
||||
" Wire nuwiki's diary hooks unless the user set a custom (non-default) one.
|
||||
" calendar-vim's own default is 'calendar#diary' (writes to ~/diary); we
|
||||
" overwrite that so paths come from the wiki root config instead.
|
||||
let l:act = get(g:, 'calendar_action', '')
|
||||
if l:act ==# '' || l:act ==# 'calendar#diary'
|
||||
let g:calendar_action = 'vimwiki#diary#calendar_action'
|
||||
endif
|
||||
let l:sign = get(g:, 'calendar_sign', '')
|
||||
if l:sign ==# '' || l:sign ==# 'calendar#sign'
|
||||
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if has('nvim')
|
||||
" Neovim path is initialised by `require('nuwiki').setup()`. Nothing else
|
||||
" to do at vimscript boot — wait until the user runs setup.
|
||||
|
||||
Reference in New Issue
Block a user