a15ae184a0
Upstream vimwiki binds bare gl/gL to remove-checkbox (item / whole list); nuwiki had rebound the conceptual keys to gl<Space>/gL<Space> as remove-done, a same-keys-different-effect parity trap. Bind bare gl/gL to remove-checkbox instead — they share the gl… prefix so they fire after 'timeoutlen', exactly as upstream. Remove-done becomes command-only; add -bang to *RemoveDone so :NuwikiRemoveDone! reaches the whole-buffer sweep that gL<Space> previously held (its only entry point). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
524 lines
39 KiB
VimL
524 lines
39 KiB
VimL
" ftplugin/nuwiki.vim — per-buffer settings + command/keymap glue.
|
|
"
|
|
" Wires up:
|
|
" - basic edit-time options (commentstring, suffixesadd, …)
|
|
" - every `:Vimwiki*` / `:Nuwiki*` command, dispatching to the
|
|
" server (or a pure client-side helper for the few that need one)
|
|
" - on Neovim: keymaps + text objects + folding via
|
|
" `nuwiki.ftplugin.attach()`
|
|
|
|
if exists('b:did_ftplugin')
|
|
finish
|
|
endif
|
|
let b:did_ftplugin = 1
|
|
|
|
setlocal commentstring=%%\ %s
|
|
setlocal comments=:%%
|
|
setlocal formatoptions+=ron
|
|
setlocal suffixesadd=.wiki
|
|
setlocal iskeyword+=-
|
|
setlocal conceallevel=2
|
|
" Reveal the cursor line's raw markup in normal mode so left/right motions
|
|
" move over visible characters instead of stalling on hidden conceal regions
|
|
" (e.g. the `[[`, target, and `]]` of a wikilink). Other lines stay concealed.
|
|
" Insert/visual already reveal the cursor line; only incsearch (`c`) keeps it
|
|
" concealed so `/` highlighting isn't disrupted.
|
|
setlocal concealcursor=c
|
|
|
|
let b:undo_ftplugin = 'setlocal commentstring< comments< formatoptions< suffixesadd< iskeyword< conceallevel< concealcursor<'
|
|
|
|
if !has('nvim')
|
|
" ===== Plain Vim path =====
|
|
"
|
|
" Define the same `:Vimwiki*` / `:Nuwiki*` surface here, dispatching
|
|
" through `autoload/nuwiki/commands.vim` (which talks to vim-lsp).
|
|
" coc.nvim users can run `:CocCommand nuwiki.x` directly and skip
|
|
" these aliases.
|
|
|
|
command! -buffer -count VimwikiIndex call nuwiki#commands#wiki_index(<count>)
|
|
command! -buffer -count VimwikiTabIndex call nuwiki#commands#wiki_tab_index(<count>)
|
|
command! -buffer VimwikiUISelect call nuwiki#commands#wiki_ui_select()
|
|
command! -buffer VimwikiDiaryIndex call nuwiki#commands#diary_index()
|
|
command! -buffer VimwikiMakeDiaryNote call nuwiki#commands#diary_today()
|
|
command! -buffer VimwikiTabMakeDiaryNote call nuwiki#commands#diary_today_tab()
|
|
command! -buffer VimwikiMakeYesterdayDiaryNote call nuwiki#commands#diary_yesterday()
|
|
command! -buffer VimwikiMakeTomorrowDiaryNote call nuwiki#commands#diary_tomorrow()
|
|
command! -buffer VimwikiDiaryNextDay call nuwiki#commands#diary_next()
|
|
command! -buffer VimwikiDiaryPrevDay call nuwiki#commands#diary_prev()
|
|
command! -buffer VimwikiDiaryGenerateLinks call nuwiki#commands#diary_generate_index()
|
|
command! -buffer VimwikiFollowLink call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer VimwikiSplitLink split | call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer VimwikiVSplitLink vsplit | call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer VimwikiTabnewLink tabnew | call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer VimwikiTabDropLink call nuwiki#commands#follow_link_drop()
|
|
command! -buffer VimwikiGoBackLink execute "normal! \<C-o>"
|
|
command! -buffer VimwikiBacklinks call nuwiki#commands#backlinks()
|
|
command! -buffer VWB call nuwiki#commands#backlinks()
|
|
command! -buffer VimwikiNextLink call nuwiki#commands#link_next()
|
|
command! -buffer VimwikiPrevLink call nuwiki#commands#link_prev()
|
|
command! -buffer VimwikiBaddLink call nuwiki#commands#badd_link()
|
|
command! -buffer -nargs=1 VimwikiSearch lvimgrep /<args>/ **
|
|
command! -buffer -nargs=1 VWS lvimgrep /<args>/ **
|
|
command! -buffer -nargs=1 VimwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
|
|
|
|
command! -buffer VimwikiDeleteFile call nuwiki#commands#delete_file()
|
|
command! -buffer VimwikiDeleteLink call nuwiki#commands#delete_file()
|
|
command! -buffer VimwikiRenameFile call nuwiki#commands#rename_file()
|
|
command! -buffer VimwikiRenameLink call nuwiki#commands#rename_file()
|
|
command! -buffer VimwikiNextTask call nuwiki#commands#next_task()
|
|
command! -buffer VimwikiToggleListItem call nuwiki#commands#toggle_list_item()
|
|
command! -buffer VimwikiToggleRejectedListItem call nuwiki#commands#reject_list_item()
|
|
command! -buffer VimwikiListToggle call nuwiki#commands#list_toggle_or_add_checkbox()
|
|
command! -buffer VimwikiIncrementListItem call nuwiki#commands#list_cycle_symbol(1)
|
|
command! -buffer VimwikiDecrementListItem call nuwiki#commands#list_cycle_symbol(-1)
|
|
command! -buffer -nargs=1 VimwikiChangeSymbolTo call nuwiki#commands#list_change_symbol(<q-args>, 0)
|
|
command! -buffer -nargs=1 VimwikiListChangeSymbolI call nuwiki#commands#list_change_symbol(<q-args>, 0)
|
|
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call nuwiki#commands#list_change_symbol(<q-args>, 1)
|
|
command! -buffer -bang VimwikiRemoveDone if <bang>0 | call nuwiki#commands#list_remove_done_all() | else | call nuwiki#commands#list_remove_done() | endif
|
|
command! -buffer -range VimwikiRemoveSingleCB call nuwiki#commands#list_remove_checkbox()
|
|
command! -buffer VimwikiRemoveCBInList call nuwiki#commands#list_remove_checkbox_in_list()
|
|
command! -buffer -nargs=? VimwikiListChangeLvl call nuwiki#commands#list_change_lvl()
|
|
command! -buffer VimwikiNormalizeLink call nuwiki#commands#normalize_link()
|
|
command! -buffer VimwikiRenumberList call nuwiki#commands#list_renumber()
|
|
command! -buffer VimwikiRenumberAllLists call nuwiki#commands#list_renumber_all()
|
|
command! -buffer VimwikiTableAlignQ call nuwiki#commands#table_align()
|
|
command! -buffer VimwikiTableAlignW call nuwiki#commands#table_align()
|
|
|
|
command! -buffer Vimwiki2HTML call nuwiki#commands#export_current()
|
|
command! -buffer Vimwiki2HTMLBrowse call nuwiki#commands#export_browse()
|
|
command! -buffer -bang VimwikiAll2HTML if <bang>0 | call nuwiki#commands#export_all_force() | else | call nuwiki#commands#export_all() | endif
|
|
command! -buffer VimwikiRss call nuwiki#commands#export_rss()
|
|
|
|
command! -buffer VimwikiTOC call nuwiki#commands#toc_generate()
|
|
command! -buffer VimwikiGenerateLinks call nuwiki#commands#links_generate()
|
|
command! -buffer VimwikiCheckLinks call nuwiki#commands#check_links()
|
|
command! -buffer VimwikiFindOrphans call nuwiki#commands#find_orphans()
|
|
|
|
command! -buffer VimwikiRebuildTags call nuwiki#commands#tags_rebuild()
|
|
command! -buffer -nargs=? VimwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
|
|
command! -buffer -nargs=? VimwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
|
|
command! -buffer -nargs=? VimwikiGenerateTags call nuwiki#commands#tags_generate_links(<q-args>)
|
|
|
|
" Tables, colorize, and clipboard paste.
|
|
command! -buffer -nargs=1 VimwikiTable call nuwiki#commands#table_insert()
|
|
command! -buffer VimwikiTableMoveColumnLeft call nuwiki#commands#table_move_left()
|
|
command! -buffer VimwikiTableMoveColumnRight call nuwiki#commands#table_move_right()
|
|
command! -buffer -nargs=1 VimwikiColorize call nuwiki#commands#colorize(<q-args>)
|
|
command! -buffer VimwikiPasteLink call nuwiki#commands#paste_link()
|
|
command! -buffer VimwikiPasteUrl call nuwiki#commands#paste_url()
|
|
command! -buffer VimwikiCatUrl call nuwiki#commands#cat_url()
|
|
|
|
" :Nuwiki* canonical aliases — Vim side.
|
|
command! -buffer -count NuwikiIndex call nuwiki#commands#wiki_index(<count>)
|
|
command! -buffer -count NuwikiTabIndex call nuwiki#commands#wiki_tab_index(<count>)
|
|
command! -buffer NuwikiDiaryIndex call nuwiki#commands#diary_index()
|
|
command! -buffer NuwikiDiaryToday call nuwiki#commands#diary_today()
|
|
command! -buffer NuwikiDiaryYesterday call nuwiki#commands#diary_yesterday()
|
|
command! -buffer NuwikiDiaryTomorrow call nuwiki#commands#diary_tomorrow()
|
|
command! -buffer NuwikiDiaryNext call nuwiki#commands#diary_next()
|
|
command! -buffer NuwikiDiaryPrev call nuwiki#commands#diary_prev()
|
|
command! -buffer NuwikiFollowLink call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer NuwikiSplitLink split | call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer NuwikiVSplitLink vsplit | call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer NuwikiTabnewLink tabnew | call nuwiki#commands#follow_link_or_create()
|
|
command! -buffer NuwikiTabDropLink call nuwiki#commands#follow_link_drop()
|
|
command! -buffer NuwikiGoBackLink execute "normal! \<C-o>"
|
|
command! -buffer NuwikiBacklinks call nuwiki#commands#backlinks()
|
|
command! -buffer NuwikiDeleteFile call nuwiki#commands#delete_file()
|
|
command! -buffer NuwikiRenameFile call nuwiki#commands#rename_file()
|
|
command! -buffer NuwikiNextTask call nuwiki#commands#next_task()
|
|
command! -buffer NuwikiToggleListItem call nuwiki#commands#toggle_list_item()
|
|
command! -buffer NuwikiToggleRejected call nuwiki#commands#reject_list_item()
|
|
command! -buffer NuwikiExport call nuwiki#commands#export_current()
|
|
command! -buffer NuwikiExportBrowse call nuwiki#commands#export_browse()
|
|
command! -buffer -bang NuwikiExportAll if <bang>0 | call nuwiki#commands#export_all_force() | else | call nuwiki#commands#export_all() | endif
|
|
command! -buffer NuwikiRss call nuwiki#commands#export_rss()
|
|
command! -buffer NuwikiTOC call nuwiki#commands#toc_generate()
|
|
command! -buffer NuwikiGenerateLinks call nuwiki#commands#links_generate()
|
|
command! -buffer NuwikiCheckLinks call nuwiki#commands#check_links()
|
|
command! -buffer NuwikiFindOrphans call nuwiki#commands#find_orphans()
|
|
command! -buffer NuwikiRebuildTags call nuwiki#commands#tags_rebuild()
|
|
command! -buffer -nargs=? NuwikiSearchTags call nuwiki#commands#tags_search(<q-args>)
|
|
command! -buffer -nargs=? NuwikiGenerateTagLinks call nuwiki#commands#tags_generate_links(<q-args>)
|
|
command! -buffer -nargs=1 NuwikiGoto call nuwiki#commands#wiki_goto_page(<q-args>)
|
|
|
|
" Canonical :Nuwiki* names that mirror the documented surface.
|
|
" The older :Nuwiki* spellings above stay defined for back-compat.
|
|
command! -buffer NuwikiNextLink call nuwiki#commands#link_next()
|
|
command! -buffer NuwikiPrevLink call nuwiki#commands#link_prev()
|
|
command! -buffer NuwikiBaddLink call nuwiki#commands#badd_link()
|
|
command! -buffer NuwikiMakeDiaryNote call nuwiki#commands#diary_today()
|
|
command! -buffer NuwikiTabMakeDiaryNote call nuwiki#commands#diary_today_tab()
|
|
command! -buffer NuwikiMakeYesterdayDiaryNote call nuwiki#commands#diary_yesterday()
|
|
command! -buffer NuwikiMakeTomorrowDiaryNote call nuwiki#commands#diary_tomorrow()
|
|
command! -buffer NuwikiDiaryGenerateLinks call nuwiki#commands#diary_generate_index()
|
|
command! -buffer NuwikiDiaryNextDay call nuwiki#commands#diary_next()
|
|
command! -buffer NuwikiDiaryPrevDay call nuwiki#commands#diary_prev()
|
|
command! -buffer Nuwiki2HTML call nuwiki#commands#export_current()
|
|
command! -buffer Nuwiki2HTMLBrowse call nuwiki#commands#export_browse()
|
|
command! -buffer -bang NuwikiAll2HTML if <bang>0 | call nuwiki#commands#export_all_force() | else | call nuwiki#commands#export_all() | endif
|
|
|
|
command! -buffer -bang NuwikiRemoveDone if <bang>0 | call nuwiki#commands#list_remove_done_all() | else | call nuwiki#commands#list_remove_done() | endif
|
|
command! -buffer -range NuwikiRemoveCheckbox call nuwiki#commands#list_remove_checkbox()
|
|
command! -buffer NuwikiRemoveCheckboxInList call nuwiki#commands#list_remove_checkbox_in_list()
|
|
command! -buffer -nargs=? NuwikiListChangeLvl call nuwiki#commands#list_change_lvl()
|
|
command! -buffer NuwikiListToggle call nuwiki#commands#list_toggle_or_add_checkbox()
|
|
command! -buffer NuwikiIncrementListItem call nuwiki#commands#list_cycle_symbol(1)
|
|
command! -buffer NuwikiDecrementListItem call nuwiki#commands#list_cycle_symbol(-1)
|
|
command! -buffer -nargs=1 NuwikiChangeSymbol call nuwiki#commands#list_change_symbol(<q-args>, 0)
|
|
command! -buffer -nargs=1 NuwikiChangeSymbolInList call nuwiki#commands#list_change_symbol(<q-args>, 1)
|
|
command! -buffer NuwikiNormalizeLink call nuwiki#commands#normalize_link()
|
|
command! -buffer NuwikiRenumberList call nuwiki#commands#list_renumber()
|
|
command! -buffer NuwikiRenumberAllLists call nuwiki#commands#list_renumber_all()
|
|
command! -buffer NuwikiTableAlign call nuwiki#commands#table_align()
|
|
command! -buffer -nargs=1 NuwikiTable call nuwiki#commands#table_insert()
|
|
command! -buffer NuwikiTableMoveColumnLeft call nuwiki#commands#table_move_left()
|
|
command! -buffer NuwikiTableMoveColumnRight call nuwiki#commands#table_move_right()
|
|
command! -buffer -nargs=1 NuwikiColorize call nuwiki#commands#colorize(<q-args>)
|
|
command! -buffer NuwikiPasteLink call nuwiki#commands#paste_link()
|
|
command! -buffer NuwikiPasteUrl call nuwiki#commands#paste_url()
|
|
command! -buffer NuwikiCatUrl call nuwiki#commands#cat_url()
|
|
|
|
" ===== Default key mappings (parity with upstream vimwiki) =====
|
|
"
|
|
" Users can opt out of the whole layer with `g:nuwiki_no_default_mappings = 1`,
|
|
" or flip individual subgroups off via `g:nuwiki_no_<group>_mappings = 1`
|
|
" (group ∈ wiki_prefix, links, lists, headers, table_editing, diary,
|
|
" html_export, text_objects). These mirror the Lua-side `mappings.<group>`
|
|
" toggles in lua/nuwiki/keymaps.lua.
|
|
|
|
if !get(g:, 'nuwiki_no_default_mappings', 0)
|
|
" Wiki prefix
|
|
if !get(g:, 'nuwiki_no_wiki_prefix_mappings', 0)
|
|
nnoremap <silent><buffer> <Leader>ww :call nuwiki#commands#wiki_index(0)<CR>
|
|
nnoremap <silent><buffer> <Leader>wt :call nuwiki#commands#wiki_tab_index(0)<CR>
|
|
nnoremap <silent><buffer> <Leader>ws :call nuwiki#commands#wiki_ui_select()<CR>
|
|
nnoremap <silent><buffer> <Leader>wi :call nuwiki#commands#diary_index()<CR>
|
|
nnoremap <silent><buffer> <Leader>w<Leader>w :call nuwiki#commands#diary_today()<CR>
|
|
nnoremap <silent><buffer> <Leader>w<Leader>y :call nuwiki#commands#diary_yesterday()<CR>
|
|
nnoremap <silent><buffer> <Leader>w<Leader>t :call nuwiki#commands#diary_tomorrow()<CR>
|
|
nnoremap <silent><buffer> <Leader>w<Leader>m :call nuwiki#commands#diary_tomorrow()<CR>
|
|
nnoremap <silent><buffer> <Leader>w<Leader>i :call nuwiki#commands#diary_generate_index()<CR>
|
|
endif
|
|
|
|
" Links
|
|
if !get(g:, 'nuwiki_no_links_mappings', 0)
|
|
nnoremap <silent><buffer> <CR> :call nuwiki#commands#follow_link_or_create()<CR>
|
|
nnoremap <silent><buffer> <S-CR> :split<CR>:call nuwiki#commands#follow_link_or_create()<CR>
|
|
nnoremap <silent><buffer> <C-CR> :vsplit<CR>:call nuwiki#commands#follow_link_or_create()<CR>
|
|
nnoremap <silent><buffer> <C-S-CR> :call nuwiki#commands#follow_link_drop()<CR>
|
|
nnoremap <silent><buffer> <BS> <C-o>
|
|
nnoremap <silent><buffer> <Tab> /\[\[<CR>:nohlsearch<CR>
|
|
nnoremap <silent><buffer> <S-Tab> ?\[\[<CR>:nohlsearch<CR>
|
|
nnoremap <silent><buffer> + :call nuwiki#commands#normalize_link()<CR>
|
|
xnoremap <silent><buffer> + :<C-u>call nuwiki#commands#normalize_link()<CR>
|
|
nnoremap <silent><buffer> <Leader>wn :call nuwiki#commands#wiki_goto_page('')<CR>
|
|
nnoremap <silent><buffer> <Leader>wd :call nuwiki#commands#delete_file()<CR>
|
|
nnoremap <silent><buffer> <Leader>wr :call nuwiki#commands#rename_file()<CR>
|
|
nnoremap <silent><buffer> <Leader>wc :call nuwiki#commands#colorize('')<CR>
|
|
xnoremap <silent><buffer> <Leader>wc :<C-u>call nuwiki#commands#colorize('')<CR>
|
|
endif
|
|
|
|
" Diary nav
|
|
if !get(g:, 'nuwiki_no_diary_mappings', 0)
|
|
nnoremap <silent><buffer> <C-Down> :call nuwiki#commands#diary_next()<CR>
|
|
nnoremap <silent><buffer> <C-Up> :call nuwiki#commands#diary_prev()<CR>
|
|
endif
|
|
|
|
" Lists
|
|
if !get(g:, 'nuwiki_no_lists_mappings', 0)
|
|
nnoremap <silent><buffer> <C-Space> :call nuwiki#commands#toggle_list_item()<CR>
|
|
xnoremap <silent><buffer> <C-Space> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
|
|
nnoremap <silent><buffer> <C-@> :call nuwiki#commands#toggle_list_item()<CR>
|
|
xnoremap <silent><buffer> <C-@> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
|
|
nnoremap <silent><buffer> <Nul> :call nuwiki#commands#toggle_list_item()<CR>
|
|
xnoremap <silent><buffer> <Nul> :<C-u>call nuwiki#commands#toggle_list_item()<CR>
|
|
nnoremap <silent><buffer> gnt :call nuwiki#commands#next_task()<CR>
|
|
nnoremap <silent><buffer> gln :call nuwiki#commands#cycle_list_item()<CR>
|
|
xnoremap <silent><buffer> gln :<C-u>call nuwiki#commands#cycle_list_item()<CR>
|
|
nnoremap <silent><buffer> glp :call nuwiki#commands#cycle_list_item_back()<CR>
|
|
xnoremap <silent><buffer> glp :<C-u>call nuwiki#commands#cycle_list_item_back()<CR>
|
|
nnoremap <silent><buffer> glx :call nuwiki#commands#reject_list_item()<CR>
|
|
xnoremap <silent><buffer> glx :<C-u>call nuwiki#commands#reject_list_item()<CR>
|
|
nnoremap <silent><buffer> glh :call nuwiki#commands#list_change_level(-1, 0)<CR>
|
|
nnoremap <silent><buffer> gll :call nuwiki#commands#list_change_level(1, 0)<CR>
|
|
nnoremap <silent><buffer> gLh :call nuwiki#commands#list_change_level(-1, 1)<CR>
|
|
nnoremap <silent><buffer> gLl :call nuwiki#commands#list_change_level(1, 1)<CR>
|
|
nnoremap <silent><buffer> glr :call nuwiki#commands#list_renumber()<CR>
|
|
nnoremap <silent><buffer> gLr :call nuwiki#commands#list_renumber_all()<CR>
|
|
" gl<sym>/gL<sym>: set the current item's / whole list's marker (upstream
|
|
" VimwikiChangeSymbolTo / ChangeSymbolInListTo). 1) is command-only.
|
|
nnoremap <silent><buffer> gl- :call nuwiki#commands#list_change_symbol('-', 0)<CR>
|
|
nnoremap <silent><buffer> gL- :call nuwiki#commands#list_change_symbol('-', 1)<CR>
|
|
nnoremap <silent><buffer> gl* :call nuwiki#commands#list_change_symbol('*', 0)<CR>
|
|
nnoremap <silent><buffer> gL* :call nuwiki#commands#list_change_symbol('*', 1)<CR>
|
|
nnoremap <silent><buffer> gl# :call nuwiki#commands#list_change_symbol('#', 0)<CR>
|
|
nnoremap <silent><buffer> gL# :call nuwiki#commands#list_change_symbol('#', 1)<CR>
|
|
nnoremap <silent><buffer> gl1 :call nuwiki#commands#list_change_symbol('1.', 0)<CR>
|
|
nnoremap <silent><buffer> gL1 :call nuwiki#commands#list_change_symbol('1.', 1)<CR>
|
|
nnoremap <silent><buffer> gli :call nuwiki#commands#list_change_symbol('i)', 0)<CR>
|
|
nnoremap <silent><buffer> gLi :call nuwiki#commands#list_change_symbol('i)', 1)<CR>
|
|
nnoremap <silent><buffer> glI :call nuwiki#commands#list_change_symbol('I)', 0)<CR>
|
|
nnoremap <silent><buffer> gLI :call nuwiki#commands#list_change_symbol('I)', 1)<CR>
|
|
nnoremap <silent><buffer> gla :call nuwiki#commands#list_change_symbol('a)', 0)<CR>
|
|
nnoremap <silent><buffer> gLa :call nuwiki#commands#list_change_symbol('a)', 1)<CR>
|
|
nnoremap <silent><buffer> glA :call nuwiki#commands#list_change_symbol('A)', 0)<CR>
|
|
nnoremap <silent><buffer> gLA :call nuwiki#commands#list_change_symbol('A)', 1)<CR>
|
|
" Bare gl/gL: remove the checkbox marker, keep the item text (upstream
|
|
" VimwikiRemoveSingleCB / RemoveCBInList). They share the `gl…` prefix
|
|
" with the maps above, so they fire after 'timeoutlen' — exactly as
|
|
" upstream. Remove-done is command-only (:NuwikiRemoveDone[!]).
|
|
nnoremap <silent><buffer> gl :call nuwiki#commands#list_remove_checkbox()<CR>
|
|
nnoremap <silent><buffer> gL :call nuwiki#commands#list_remove_checkbox_in_list()<CR>
|
|
nnoremap <silent><buffer> o :call nuwiki#commands#open_below_with_bullet()<CR>
|
|
nnoremap <silent><buffer> O :call nuwiki#commands#open_above_with_bullet()<CR>
|
|
|
|
" Insert-mode list editing (vimwiki parity).
|
|
inoremap <silent><buffer> <C-D> <C-o>:call nuwiki#commands#list_change_level(-1, 0)<CR>
|
|
inoremap <silent><buffer> <C-T> <C-o>:call nuwiki#commands#list_change_level(1, 0)<CR>
|
|
inoremap <silent><buffer> <C-L><C-J> <C-o>:call nuwiki#commands#list_cycle_symbol(1)<CR>
|
|
inoremap <silent><buffer> <C-L><C-K> <C-o>:call nuwiki#commands#list_cycle_symbol(-1)<CR>
|
|
inoremap <silent><buffer> <C-L><C-M> <C-o>:call nuwiki#commands#list_toggle_or_add_checkbox()<CR>
|
|
inoremap <silent><buffer><expr> <CR> nuwiki#commands#smart_return()
|
|
endif
|
|
|
|
" Headers
|
|
if !get(g:, 'nuwiki_no_headers_mappings', 0)
|
|
nnoremap <silent><buffer> = :call nuwiki#commands#heading_add()<CR>
|
|
nnoremap <silent><buffer> - :call nuwiki#commands#heading_remove()<CR>
|
|
nnoremap <silent><buffer> ]] :call nuwiki#commands#next_header()<CR>
|
|
nnoremap <silent><buffer> [[ :call nuwiki#commands#prev_header()<CR>
|
|
nnoremap <silent><buffer> ]= :call nuwiki#commands#next_sibling_header()<CR>
|
|
nnoremap <silent><buffer> [= :call nuwiki#commands#prev_sibling_header()<CR>
|
|
nnoremap <silent><buffer> ]u :call nuwiki#commands#parent_header()<CR>
|
|
nnoremap <silent><buffer> [u :call nuwiki#commands#parent_header()<CR>
|
|
endif
|
|
|
|
" HTML export
|
|
if !get(g:, 'nuwiki_no_html_export_mappings', 0)
|
|
nnoremap <silent><buffer> <Leader>wh :call nuwiki#commands#export_current()<CR>
|
|
nnoremap <silent><buffer> <Leader>whh :call nuwiki#commands#export_browse()<CR>
|
|
nnoremap <silent><buffer> <Leader>wha :call nuwiki#commands#export_all()<CR>
|
|
endif
|
|
|
|
" Mouse (opt-in via g:nuwiki_mouse_mappings = 1).
|
|
if get(g:, 'nuwiki_mouse_mappings', 0)
|
|
nnoremap <silent><buffer> <2-LeftMouse> :call nuwiki#commands#follow_link_or_create()<CR>
|
|
nnoremap <silent><buffer> <S-2-LeftMouse> :split<CR>:call nuwiki#commands#follow_link_or_create()<CR>
|
|
nnoremap <silent><buffer> <C-2-LeftMouse> :vsplit<CR>:call nuwiki#commands#follow_link_or_create()<CR>
|
|
nnoremap <silent><buffer> <MiddleMouse> :call nuwiki#commands#badd_link()<CR>
|
|
nnoremap <silent><buffer> <RightMouse> <C-o>
|
|
endif
|
|
|
|
" Tables (and insert-mode table-cell navigation, same surface).
|
|
if !get(g:, 'nuwiki_no_table_editing_mappings', 0)
|
|
nnoremap <silent><buffer> gqq :call nuwiki#commands#table_align()<CR>
|
|
nnoremap <silent><buffer> gq1 :call nuwiki#commands#table_align()<CR>
|
|
nnoremap <silent><buffer> gww :call nuwiki#commands#table_align()<CR>
|
|
nnoremap <silent><buffer> gw1 :call nuwiki#commands#table_align()<CR>
|
|
nnoremap <silent><buffer> <A-Left> :call nuwiki#commands#table_move_left()<CR>
|
|
nnoremap <silent><buffer> <A-Right> :call nuwiki#commands#table_move_right()<CR>
|
|
inoremap <silent><buffer><expr> <Tab> nuwiki#commands#smart_tab()
|
|
inoremap <silent><buffer><expr> <S-Tab> nuwiki#commands#smart_shift_tab()
|
|
endif
|
|
|
|
" Folding — heading-block fold structure (matches lua/nuwiki/folding.lua).
|
|
" Opt-out via `let g:nuwiki_no_folding = 1` (mirrors the Lua-side
|
|
" `folding = false` toggle on `setup()`).
|
|
if !get(g:, 'nuwiki_no_folding', 0)
|
|
setlocal foldmethod=expr
|
|
setlocal foldexpr=nuwiki#folding#expr()
|
|
setlocal foldtext=nuwiki#folding#foldtext()
|
|
" Start with every heading-block fold open; the user can still close
|
|
" them with `zc` and that state survives because `foldlevel` only
|
|
" controls the initial state, not subsequent manual fold operations.
|
|
setlocal foldlevel=99
|
|
let b:undo_ftplugin .= ' | setlocal foldmethod< foldexpr< foldtext< foldlevel<'
|
|
endif
|
|
|
|
" Text objects — vimwiki parity (matches lua/nuwiki/textobjects.lua).
|
|
" The `:<C-u>` clears any prefix count and the visual mode; the
|
|
" autoload function re-establishes the selection at the right range.
|
|
if !get(g:, 'nuwiki_no_text_objects_mappings', 0)
|
|
xnoremap <silent><buffer> ah :<C-u>call nuwiki#textobjects#heading(0, 0)<CR>
|
|
onoremap <silent><buffer> ah :<C-u>call nuwiki#textobjects#heading(0, 0)<CR>
|
|
xnoremap <silent><buffer> ih :<C-u>call nuwiki#textobjects#heading(1, 0)<CR>
|
|
onoremap <silent><buffer> ih :<C-u>call nuwiki#textobjects#heading(1, 0)<CR>
|
|
xnoremap <silent><buffer> aH :<C-u>call nuwiki#textobjects#heading(0, 1)<CR>
|
|
onoremap <silent><buffer> aH :<C-u>call nuwiki#textobjects#heading(0, 1)<CR>
|
|
xnoremap <silent><buffer> iH :<C-u>call nuwiki#textobjects#heading(1, 1)<CR>
|
|
onoremap <silent><buffer> iH :<C-u>call nuwiki#textobjects#heading(1, 1)<CR>
|
|
xnoremap <silent><buffer> al :<C-u>call nuwiki#textobjects#list_item(0)<CR>
|
|
onoremap <silent><buffer> al :<C-u>call nuwiki#textobjects#list_item(0)<CR>
|
|
xnoremap <silent><buffer> il :<C-u>call nuwiki#textobjects#list_item(1)<CR>
|
|
onoremap <silent><buffer> il :<C-u>call nuwiki#textobjects#list_item(1)<CR>
|
|
xnoremap <silent><buffer> a\ :<C-u>call nuwiki#textobjects#table_cell(0)<CR>
|
|
onoremap <silent><buffer> a\ :<C-u>call nuwiki#textobjects#table_cell(0)<CR>
|
|
xnoremap <silent><buffer> i\ :<C-u>call nuwiki#textobjects#table_cell(1)<CR>
|
|
onoremap <silent><buffer> i\ :<C-u>call nuwiki#textobjects#table_cell(1)<CR>
|
|
xnoremap <silent><buffer> ac :<C-u>call nuwiki#textobjects#table_column(0)<CR>
|
|
onoremap <silent><buffer> ac :<C-u>call nuwiki#textobjects#table_column(0)<CR>
|
|
xnoremap <silent><buffer> ic :<C-u>call nuwiki#textobjects#table_column(1)<CR>
|
|
onoremap <silent><buffer> ic :<C-u>call nuwiki#textobjects#table_column(1)<CR>
|
|
endif
|
|
endif
|
|
|
|
finish
|
|
endif
|
|
|
|
" ===== Neovim path =====
|
|
|
|
" :Vimwiki* compat — every command dispatches to a Lua wrapper in
|
|
" `nuwiki.commands` that either issues a `workspace/executeCommand`
|
|
" or, for client-side operations, calls `vim.lsp.buf.*` directly.
|
|
|
|
command! -buffer -count VimwikiIndex lua require('nuwiki.commands').wiki_index(vim.v.count)
|
|
command! -buffer -count VimwikiTabIndex lua require('nuwiki.commands').wiki_tab_index(vim.v.count)
|
|
command! -buffer VimwikiUISelect lua require('nuwiki.commands').wiki_ui_select()
|
|
command! -buffer VimwikiDiaryIndex lua require('nuwiki.commands').diary_index()
|
|
command! -buffer VimwikiMakeDiaryNote lua require('nuwiki.commands').diary_today()
|
|
command! -buffer VimwikiTabMakeDiaryNote lua require('nuwiki.commands').diary_today_tab()
|
|
command! -buffer VimwikiMakeYesterdayDiaryNote lua require('nuwiki.commands').diary_yesterday()
|
|
command! -buffer VimwikiMakeTomorrowDiaryNote lua require('nuwiki.commands').diary_tomorrow()
|
|
command! -buffer VimwikiDiaryNextDay lua require('nuwiki.commands').diary_next()
|
|
command! -buffer VimwikiDiaryPrevDay lua require('nuwiki.commands').diary_prev()
|
|
command! -buffer VimwikiDiaryGenerateLinks lua require('nuwiki.commands').diary_generate_index()
|
|
|
|
command! -buffer VimwikiFollowLink lua vim.lsp.buf.definition()
|
|
command! -buffer VimwikiGoBackLink execute "normal! \<C-o>"
|
|
command! -buffer VimwikiSplitLink split | lua vim.lsp.buf.definition()
|
|
command! -buffer VimwikiVSplitLink vsplit | lua vim.lsp.buf.definition()
|
|
command! -buffer VimwikiTabnewLink tabnew | lua vim.lsp.buf.definition()
|
|
command! -buffer VimwikiTabDropLink lua require('nuwiki.commands').follow_link_drop()
|
|
command! -buffer VimwikiNextLink lua require('nuwiki.commands').link_next()
|
|
command! -buffer VimwikiPrevLink lua require('nuwiki.commands').link_prev()
|
|
command! -buffer VimwikiBaddLink lua require('nuwiki.commands').badd_link()
|
|
command! -buffer -nargs=1 VimwikiGoto lua require('nuwiki.commands').wiki_goto_page(<q-args>)
|
|
command! -buffer VimwikiBacklinks lua vim.lsp.buf.references()
|
|
command! -buffer VWB lua vim.lsp.buf.references()
|
|
command! -buffer -nargs=1 VimwikiSearch lvimgrep /<args>/ **
|
|
command! -buffer -nargs=1 VWS lvimgrep /<args>/ **
|
|
|
|
command! -buffer VimwikiDeleteFile lua require('nuwiki.commands').delete_file()
|
|
command! -buffer VimwikiDeleteLink lua require('nuwiki.commands').delete_file()
|
|
command! -buffer VimwikiRenameFile lua require('nuwiki.commands').rename_file()
|
|
command! -buffer VimwikiRenameLink lua require('nuwiki.commands').rename_file()
|
|
|
|
command! -buffer VimwikiNextTask lua require('nuwiki.commands').next_task()
|
|
command! -buffer VimwikiToggleListItem lua require('nuwiki.commands').toggle_list_item()
|
|
command! -buffer VimwikiToggleRejectedListItem lua require('nuwiki.commands').reject_list_item()
|
|
command! -buffer VimwikiListToggle lua require('nuwiki.commands').list_toggle_or_add_checkbox()
|
|
command! -buffer VimwikiIncrementListItem lua require('nuwiki.commands').list_cycle_symbol(1)
|
|
command! -buffer VimwikiDecrementListItem lua require('nuwiki.commands').list_cycle_symbol(-1)
|
|
command! -buffer -nargs=1 VimwikiChangeSymbolTo lua require('nuwiki.commands').list_change_symbol(<q-args>, false)
|
|
command! -buffer -nargs=1 VimwikiListChangeSymbolI lua require('nuwiki.commands').list_change_symbol(<q-args>, false)
|
|
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo lua require('nuwiki.commands').list_change_symbol(<q-args>, true)
|
|
command! -buffer -bang VimwikiRemoveDone lua require('nuwiki.commands')[('<bang>' == '!') and 'list_remove_done_all' or 'list_remove_done']()
|
|
command! -buffer -range VimwikiRemoveSingleCB lua require('nuwiki.commands').list_remove_checkbox()
|
|
command! -buffer VimwikiRemoveCBInList lua require('nuwiki.commands').list_remove_checkbox_in_list()
|
|
command! -buffer -nargs=? VimwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl()
|
|
command! -buffer VimwikiNormalizeLink lua require('nuwiki.commands').normalize_link()
|
|
command! -buffer VimwikiRenumberList lua require('nuwiki.commands').list_renumber()
|
|
command! -buffer VimwikiRenumberAllLists lua require('nuwiki.commands').list_renumber_all()
|
|
command! -buffer VimwikiTableAlignQ lua require('nuwiki.commands').table_align()
|
|
command! -buffer VimwikiTableAlignW lua require('nuwiki.commands').table_align()
|
|
|
|
command! -buffer Vimwiki2HTML lua require('nuwiki.commands').export_current()
|
|
command! -buffer Vimwiki2HTMLBrowse lua require('nuwiki.commands').export_browse()
|
|
command! -buffer -bang VimwikiAll2HTML execute (<bang>0 ? "lua require('nuwiki.commands').export_all_force()" : "lua require('nuwiki.commands').export_all()")
|
|
command! -buffer VimwikiRss lua require('nuwiki.commands').export_rss()
|
|
|
|
command! -buffer VimwikiTOC lua require('nuwiki.commands').toc_generate()
|
|
command! -buffer VimwikiGenerateLinks lua require('nuwiki.commands').links_generate()
|
|
command! -buffer VimwikiCheckLinks lua require('nuwiki.commands').check_links()
|
|
command! -buffer VimwikiFindOrphans lua require('nuwiki.commands').find_orphans()
|
|
|
|
command! -buffer VimwikiRebuildTags lua require('nuwiki.commands').tags_rebuild()
|
|
command! -buffer -nargs=? VimwikiSearchTags lua require('nuwiki.commands').tags_search(<q-args>)
|
|
command! -buffer -nargs=? VimwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links(<q-args>)
|
|
command! -buffer -nargs=? VimwikiGenerateTags lua require('nuwiki.commands').tags_generate_links(<q-args>)
|
|
|
|
" Tables, colorize, and clipboard paste.
|
|
command! -buffer -nargs=1 VimwikiTable lua require('nuwiki.commands').table_insert()
|
|
command! -buffer VimwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left()
|
|
command! -buffer VimwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right()
|
|
command! -buffer -nargs=1 VimwikiColorize lua require('nuwiki.commands').colorize()
|
|
command! -buffer VimwikiPasteLink lua require('nuwiki.commands').paste_link()
|
|
command! -buffer VimwikiPasteUrl lua require('nuwiki.commands').paste_url()
|
|
command! -buffer VimwikiCatUrl lua require('nuwiki.commands').cat_url()
|
|
|
|
" Canonical :Nuwiki* aliases — P10.
|
|
command! -buffer -count NuwikiIndex lua require('nuwiki.commands').wiki_index(vim.v.count)
|
|
command! -buffer NuwikiTabIndex lua require('nuwiki.commands').wiki_tab_index(vim.v.count)
|
|
command! -buffer NuwikiUISelect lua require('nuwiki.commands').wiki_ui_select()
|
|
command! -buffer NuwikiDiaryIndex lua require('nuwiki.commands').diary_index()
|
|
command! -buffer NuwikiDiaryToday lua require('nuwiki.commands').diary_today()
|
|
command! -buffer NuwikiDiaryYesterday lua require('nuwiki.commands').diary_yesterday()
|
|
command! -buffer NuwikiDiaryTomorrow lua require('nuwiki.commands').diary_tomorrow()
|
|
command! -buffer NuwikiDiaryNext lua require('nuwiki.commands').diary_next()
|
|
command! -buffer NuwikiDiaryPrev lua require('nuwiki.commands').diary_prev()
|
|
command! -buffer NuwikiDiaryGenerateLinks lua require('nuwiki.commands').diary_generate_index()
|
|
command! -buffer NuwikiFollowLink lua vim.lsp.buf.definition()
|
|
command! -buffer NuwikiBacklinks lua vim.lsp.buf.references()
|
|
command! -buffer NuwikiDeleteFile lua require('nuwiki.commands').delete_file()
|
|
command! -buffer NuwikiRenameFile lua require('nuwiki.commands').rename_file()
|
|
command! -buffer NuwikiNextTask lua require('nuwiki.commands').next_task()
|
|
command! -buffer NuwikiToggleListItem lua require('nuwiki.commands').toggle_list_item()
|
|
command! -buffer NuwikiToggleRejected lua require('nuwiki.commands').reject_list_item()
|
|
command! -buffer NuwikiExport lua require('nuwiki.commands').export_current()
|
|
command! -buffer NuwikiExportBrowse lua require('nuwiki.commands').export_browse()
|
|
command! -buffer -bang NuwikiExportAll execute (<bang>0 ? "lua require('nuwiki.commands').export_all_force()" : "lua require('nuwiki.commands').export_all()")
|
|
command! -buffer NuwikiRss lua require('nuwiki.commands').export_rss()
|
|
command! -buffer NuwikiTOC lua require('nuwiki.commands').toc_generate()
|
|
command! -buffer NuwikiGenerateLinks lua require('nuwiki.commands').links_generate()
|
|
command! -buffer NuwikiCheckLinks lua require('nuwiki.commands').check_links()
|
|
command! -buffer NuwikiFindOrphans lua require('nuwiki.commands').find_orphans()
|
|
command! -buffer NuwikiRebuildTags lua require('nuwiki.commands').tags_rebuild()
|
|
command! -buffer -nargs=? NuwikiSearchTags lua require('nuwiki.commands').tags_search(<q-args>)
|
|
command! -buffer -nargs=? NuwikiGenerateTagLinks lua require('nuwiki.commands').tags_generate_links(<q-args>)
|
|
command! -buffer -nargs=1 NuwikiGoto lua require('nuwiki.commands').wiki_goto_page(<q-args>)
|
|
|
|
" Canonical :Nuwiki* names that mirror the documented surface.
|
|
" The older :Nuwiki* spellings above stay defined for back-compat.
|
|
command! -buffer NuwikiNextLink lua require('nuwiki.commands').link_next()
|
|
command! -buffer NuwikiPrevLink lua require('nuwiki.commands').link_prev()
|
|
command! -buffer NuwikiBaddLink lua require('nuwiki.commands').badd_link()
|
|
command! -buffer NuwikiMakeDiaryNote lua require('nuwiki.commands').diary_today()
|
|
command! -buffer NuwikiTabMakeDiaryNote lua require('nuwiki.commands').diary_today_tab()
|
|
command! -buffer NuwikiMakeYesterdayDiaryNote lua require('nuwiki.commands').diary_yesterday()
|
|
command! -buffer NuwikiMakeTomorrowDiaryNote lua require('nuwiki.commands').diary_tomorrow()
|
|
command! -buffer NuwikiDiaryNextDay lua require('nuwiki.commands').diary_next()
|
|
command! -buffer NuwikiDiaryPrevDay lua require('nuwiki.commands').diary_prev()
|
|
command! -buffer Nuwiki2HTML lua require('nuwiki.commands').export_current()
|
|
command! -buffer Nuwiki2HTMLBrowse lua require('nuwiki.commands').export_browse()
|
|
command! -buffer -bang NuwikiAll2HTML execute (<bang>0 ? "lua require('nuwiki.commands').export_all_force()" : "lua require('nuwiki.commands').export_all()")
|
|
|
|
command! -buffer NuwikiGoBackLink execute "normal! \<C-o>"
|
|
command! -buffer NuwikiSplitLink split | lua vim.lsp.buf.definition()
|
|
command! -buffer NuwikiVSplitLink vsplit | lua vim.lsp.buf.definition()
|
|
command! -buffer NuwikiTabnewLink tabnew | lua vim.lsp.buf.definition()
|
|
command! -buffer NuwikiTabDropLink lua require('nuwiki.commands').follow_link_drop()
|
|
command! -buffer -bang NuwikiRemoveDone lua require('nuwiki.commands')[('<bang>' == '!') and 'list_remove_done_all' or 'list_remove_done']()
|
|
command! -buffer -range NuwikiRemoveCheckbox lua require('nuwiki.commands').list_remove_checkbox()
|
|
command! -buffer NuwikiRemoveCheckboxInList lua require('nuwiki.commands').list_remove_checkbox_in_list()
|
|
command! -buffer -nargs=? NuwikiListChangeLvl lua require('nuwiki.commands').list_change_lvl()
|
|
command! -buffer NuwikiListToggle lua require('nuwiki.commands').list_toggle_or_add_checkbox()
|
|
command! -buffer NuwikiIncrementListItem lua require('nuwiki.commands').list_cycle_symbol(1)
|
|
command! -buffer NuwikiDecrementListItem lua require('nuwiki.commands').list_cycle_symbol(-1)
|
|
command! -buffer -nargs=1 NuwikiChangeSymbol lua require('nuwiki.commands').list_change_symbol(<q-args>, false)
|
|
command! -buffer -nargs=1 NuwikiChangeSymbolInList lua require('nuwiki.commands').list_change_symbol(<q-args>, true)
|
|
command! -buffer NuwikiNormalizeLink lua require('nuwiki.commands').normalize_link()
|
|
command! -buffer NuwikiRenumberList lua require('nuwiki.commands').list_renumber()
|
|
command! -buffer NuwikiRenumberAllLists lua require('nuwiki.commands').list_renumber_all()
|
|
command! -buffer NuwikiTableAlign lua require('nuwiki.commands').table_align()
|
|
command! -buffer -nargs=1 NuwikiTable lua require('nuwiki.commands').table_insert()
|
|
command! -buffer NuwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left()
|
|
command! -buffer NuwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right()
|
|
command! -buffer -nargs=1 NuwikiColorize lua require('nuwiki.commands').colorize()
|
|
command! -buffer NuwikiPasteLink lua require('nuwiki.commands').paste_link()
|
|
command! -buffer NuwikiPasteUrl lua require('nuwiki.commands').paste_url()
|
|
command! -buffer NuwikiCatUrl lua require('nuwiki.commands').cat_url()
|
|
|
|
" Buffer attach: keymaps + text objects + folding.
|
|
lua require('nuwiki.ftplugin').attach(0)
|