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:
@@ -275,6 +275,20 @@ reset_dirs() {
|
||||
done
|
||||
}
|
||||
|
||||
# ensure_calendar_vim — clone calendar-vim into dev dir for testing
|
||||
ensure_calendar_vim() {
|
||||
local repo="$DEV_DIR/calendar-vim"
|
||||
if [[ -d "$repo/.git" ]]; then
|
||||
return
|
||||
fi
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
log "git not found — skipping calendar-vim"
|
||||
return 1
|
||||
fi
|
||||
log "cloning https://github.com/mattn/calendar-vim.git → $repo"
|
||||
git clone --depth 1 https://github.com/mattn/calendar-vim.git "$repo" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
seed_wiki() {
|
||||
if [[ "${NUWIKI_DEV_NO_SEED:-0}" == "1" ]]; then
|
||||
log "NUWIKI_DEV_NO_SEED=1 — skipping wiki seed (using $WIKI_DIR as-is)"
|
||||
|
||||
@@ -54,17 +54,13 @@ vim.env.XDG_DATA_HOME = '$DATA_DIR'
|
||||
vim.env.XDG_CONFIG_HOME = '$CONFIG_DIR'
|
||||
|
||||
vim.opt.runtimepath:prepend('$REPO_ROOT')
|
||||
vim.opt.runtimepath:append('$DEV_DIR/calendar-vim')
|
||||
|
||||
vim.g.nuwiki_binary_path = '$REPO_ROOT/bin/nuwiki-ls'
|
||||
|
||||
-- Friendly defaults for an interactive smoke test.
|
||||
vim.opt.number = true
|
||||
vim.opt.signcolumn = 'yes'
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.undofile = false
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.nuwiki_wiki_root = '$WIKI_DIR'
|
||||
vim.g.nuwiki_file_extension = '.wiki'
|
||||
vim.g.nuwiki_syntax = 'vimwiki'
|
||||
vim.g.nuwiki_diary_rel_path = 'diary'
|
||||
|
||||
require('nuwiki').setup({
|
||||
wiki_root = '$WIKI_DIR',
|
||||
@@ -74,13 +70,14 @@ require('nuwiki').setup({
|
||||
-- they're swallowed; with it they land in :messages.
|
||||
vim.lsp.set_log_level('info')
|
||||
|
||||
print('[nuwiki-dev] ready — wiki root: $WIKI_DIR')
|
||||
print('[nuwiki-dev] ready — wiki root: ' .. '$WIKI_DIR')
|
||||
print('[nuwiki-dev] :LspInfo to inspect, :checkhealth nuwiki for diagnostics')
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
ensure_binary
|
||||
ensure_calendar_vim
|
||||
seed_wiki
|
||||
write_init
|
||||
reset_dirs "$STATE_DIR" "$DATA_DIR" "$CONFIG_DIR"
|
||||
|
||||
@@ -114,25 +114,27 @@ write_vimrc() {
|
||||
|
||||
" Confine state to the dev cache so we never touch the user's real Vim
|
||||
" install.
|
||||
set viminfo='100,n$VIM_STATE/viminfo
|
||||
let &directory = '$VIM_STATE/swap//'
|
||||
let &backupdir = '$VIM_STATE/backup//'
|
||||
let &undodir = '$VIM_STATE/undo//'
|
||||
set viminfo='100,n${VIM_STATE}/viminfo
|
||||
let &directory = '${VIM_STATE}/swap//'
|
||||
let &backupdir = '${VIM_STATE}/backup//'
|
||||
let &undodir = '${VIM_STATE}/undo//'
|
||||
|
||||
" Make Vim look for runtime paths in the dev cache. vim-lsp is intentionally
|
||||
" absent so nuwiki dispatches jump-to-definition through coc.
|
||||
set nocompatible
|
||||
let &runtimepath = '$REPO_ROOT' . ',' . &runtimepath
|
||||
let &runtimepath .= ',$COC_DIR'
|
||||
let &runtimepath = '${REPO_ROOT}' . ',' . &runtimepath
|
||||
let &runtimepath .= ',${COC_DIR}'
|
||||
let &runtimepath .= ',${DEV_DIR}/calendar-vim'
|
||||
|
||||
" Point coc at the generated settings + a private data dir.
|
||||
let g:coc_config_home = '$DEV_DIR'
|
||||
let g:coc_data_home = '$COC_DATA'
|
||||
let g:coc_config_home = '${DEV_DIR}'
|
||||
let g:coc_data_home = '${COC_DATA}'
|
||||
|
||||
let g:nuwiki_binary_path = '$REPO_ROOT/bin/nuwiki-ls'
|
||||
let g:nuwiki_wiki_root = '$WIKI_DIR'
|
||||
let g:nuwiki_binary_path = '${REPO_ROOT}/bin/nuwiki-ls'
|
||||
let g:nuwiki_wiki_root = '${WIKI_DIR}'
|
||||
let g:nuwiki_file_extension = '.wiki'
|
||||
let g:nuwiki_syntax = 'vimwiki'
|
||||
let g:nuwiki_diary_rel_path = 'diary'
|
||||
let g:nuwiki_log_level = 'info'
|
||||
|
||||
filetype plugin indent on
|
||||
@@ -153,11 +155,8 @@ augroup NuwikiFtdetect
|
||||
autocmd BufRead,BufNewFile *.wiki setfiletype vimwiki
|
||||
augroup END
|
||||
|
||||
" coc starts the server automatically from coc-settings.json once a vimwiki
|
||||
" buffer loads — no explicit nuwiki#lsp#start() needed.
|
||||
|
||||
echomsg '[nuwiki-dev] ready (coc.nvim) — wiki root: $WIKI_DIR'
|
||||
echomsg '[nuwiki-dev] coc.preferences.jumpCommand = $COC_JUMP'
|
||||
echo
|
||||
echomsg '[nuwiki-dev] coc.preferences.jumpCommand = ' . '\$COC_JUMP'
|
||||
echomsg '[nuwiki-dev] <CR> on a [[link]] should open in the CURRENT window'
|
||||
echomsg '[nuwiki-dev] :CocList services for status, :messages for log'
|
||||
EOF
|
||||
@@ -167,6 +166,7 @@ main() {
|
||||
ensure_node
|
||||
ensure_binary
|
||||
ensure_coc
|
||||
ensure_calendar_vim
|
||||
write_coc_settings
|
||||
seed_wiki
|
||||
write_vimrc
|
||||
|
||||
+12
-11
@@ -70,19 +70,20 @@ write_vimrc() {
|
||||
|
||||
" Confine state to the dev cache so we never touch the user's real Vim
|
||||
" install.
|
||||
set viminfo='100,n$VIM_STATE/viminfo
|
||||
let &directory = '$VIM_STATE/swap//'
|
||||
let &backupdir = '$VIM_STATE/backup//'
|
||||
let &undodir = '$VIM_STATE/undo//'
|
||||
set viminfo='100,n${VIM_STATE}/viminfo
|
||||
let &directory = '${VIM_STATE}/swap//'
|
||||
let &backupdir = '${VIM_STATE}/backup//'
|
||||
let &undodir = '${VIM_STATE}/undo//'
|
||||
|
||||
" Make Vim look for runtime paths in the dev cache.
|
||||
set nocompatible
|
||||
let &runtimepath = '$REPO_ROOT' . ',' . &runtimepath
|
||||
let &runtimepath .= ',$VIM_LSP_DIR'
|
||||
let &runtimepath .= ',$ASYNC_DIR'
|
||||
let &runtimepath = '${REPO_ROOT}' . ',' . &runtimepath
|
||||
let &runtimepath .= ',${VIM_LSP_DIR}'
|
||||
let &runtimepath .= ',${ASYNC_DIR}'
|
||||
let &runtimepath .= ',${DEV_DIR}/calendar-vim'
|
||||
|
||||
let g:nuwiki_binary_path = '$REPO_ROOT/bin/nuwiki-ls'
|
||||
let g:nuwiki_wiki_root = '$WIKI_DIR'
|
||||
let g:nuwiki_binary_path = '${REPO_ROOT}/bin/nuwiki-ls'
|
||||
let g:nuwiki_wiki_root = '${WIKI_DIR}'
|
||||
let g:nuwiki_file_extension = '.wiki'
|
||||
let g:nuwiki_syntax = 'vimwiki'
|
||||
let g:nuwiki_log_level = 'info'
|
||||
@@ -113,8 +114,7 @@ augroup NuwikiStart
|
||||
autocmd FileType vimwiki call nuwiki#lsp#start()
|
||||
augroup END
|
||||
|
||||
" Status messages go to :messages so they don't trigger "Press ENTER".
|
||||
echomsg '[nuwiki-dev] ready — wiki root: $WIKI_DIR'
|
||||
echomsg '[nuwiki-dev] ready — wiki root: ' . g:nuwiki_wiki_root
|
||||
echomsg '[nuwiki-dev] :LspStatus for diagnostics, :messages for log'
|
||||
EOF
|
||||
}
|
||||
@@ -122,6 +122,7 @@ EOF
|
||||
main() {
|
||||
ensure_binary
|
||||
ensure_vim_lsp
|
||||
ensure_calendar_vim
|
||||
seed_wiki
|
||||
write_vimrc
|
||||
reset_dirs "$VIM_STATE"
|
||||
|
||||
Reference in New Issue
Block a user