9354e1c176
Two bugs prevented keymaps from working after a Dein install: 1. <Leader>ww and <Leader>wt both called diary_today() instead of wiki_index() / wiki_tab_index(). Fixed in keymaps.lua (Neovim) and ftplugin/vimwiki.vim (Vim). 2. All keymaps were buffer-local (<buffer> / buffer=bufnr), so they only activated inside an already-open .wiki file. Users had no way to reach the wiki from any other buffer, making the plugin appear broken on a fresh Vim start. Fix: register the eight <Leader>w* entry-point mappings globally — in setup() for Neovim (lua/nuwiki/init.lua) and in plugin/nuwiki.vim for plain Vim. To avoid a chicken-and-egg LSP dependency, the global mappings open files directly from config (wiki_root, diary_rel_path, file_extension); the LSP auto-starts via the FileType autocmd once the vimwiki buffer loads. Three new autoload helpers (open_wiki_path, open_diary_path, open_diary_index_path) provide the LSP-free path for the Vim side. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
2.0 KiB
VimL
44 lines
2.0 KiB
VimL
" plugin/nuwiki.vim — universal Vim/Neovim entry point.
|
|
"
|
|
" Neovim 0.11+ users are expected to call `require('nuwiki').setup({})` from
|
|
" their config (lazy.nvim does this automatically through `opts`). On Vim
|
|
" we start the LSP client when a vimwiki buffer is loaded.
|
|
"
|
|
" Per SPEC §6.2 / §6.3 this file contains wiring only — all logic lives in
|
|
" the Rust language server.
|
|
|
|
if exists('g:loaded_nuwiki')
|
|
finish
|
|
endif
|
|
let g:loaded_nuwiki = 1
|
|
|
|
if has('nvim')
|
|
" Neovim path is initialised by `require('nuwiki').setup()`. Nothing else
|
|
" to do at vimscript boot — wait until the user runs setup.
|
|
finish
|
|
endif
|
|
|
|
" Vim path: start the LSP client the first time a vimwiki buffer is opened.
|
|
augroup nuwiki_vim_lsp_start
|
|
autocmd!
|
|
autocmd FileType vimwiki call nuwiki#lsp#start()
|
|
augroup END
|
|
|
|
" :NuwikiInstall — convenience wrapper around scripts/download_bin.vim, so
|
|
" users don't have to invoke a plugin-manager build hook by hand.
|
|
command! -nargs=0 NuwikiInstall execute 'source' fnamemodify(resolve(expand('<sfile>:p')), ':h:h') . '/scripts/download_bin.vim'
|
|
|
|
" Global entry-point mappings — work from any buffer, not just .wiki files.
|
|
" Files are opened directly from config (no LSP required); the server
|
|
" auto-starts via the FileType autocmd once the vimwiki buffer loads.
|
|
if !get(g:, 'nuwiki_no_default_mappings', 0)
|
|
nnoremap <silent> <Leader>ww :call nuwiki#commands#open_wiki_path(0)<CR>
|
|
nnoremap <silent> <Leader>wt :call nuwiki#commands#open_wiki_path(1)<CR>
|
|
nnoremap <silent> <Leader>ws :call nuwiki#commands#wiki_ui_select()<CR>
|
|
nnoremap <silent> <Leader>wi :call nuwiki#commands#open_diary_index_path()<CR>
|
|
nnoremap <silent> <Leader>w<Leader>w :call nuwiki#commands#open_diary_path(0)<CR>
|
|
nnoremap <silent> <Leader>w<Leader>y :call nuwiki#commands#open_diary_path(-1)<CR>
|
|
nnoremap <silent> <Leader>w<Leader>t :call nuwiki#commands#open_diary_path(1)<CR>
|
|
nnoremap <silent> <Leader>w<Leader>i :call nuwiki#commands#diary_generate_index()<CR>
|
|
endif
|