From ee31d45553a7b6cdada5db2ac5f3983c732a7927 Mon Sep 17 00:00:00 2001 From: Jean-Luc Bastarache Date: Sat, 18 Dec 2021 10:08:54 -0500 Subject: [PATCH] Feature: Add wiki page to buffer list using `badd` (#1185) Co-authored-by: Tinmarino --- autoload/vimwiki/base.vim | 2 ++ doc/vimwiki.txt | 14 ++++++++++++++ ftplugin/vimwiki.vim | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 8cfb169..685fa5c 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1660,6 +1660,8 @@ function! vimwiki#base#follow_link(split, ...) abort let cmd = ':split ' elseif a:split ==# 'vsplit' let cmd = ':vsplit ' + elseif a:split ==# 'badd' + let cmd = ':badd ' elseif a:split ==# 'tab' let cmd = ':tabnew ' else diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 639eb8d..60d6e68 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -359,6 +359,13 @@ MAP MODE Maps to |:VimwikiVSplitLink|. Remap command: `VimwikiVSplitLink` + *vimwiki_* + n Add to the buffer list, without loading, if it wasn't + listed yet (create target wiki page if needed). May + not work in some terminals. Remapping could help. + Maps to |:VimwikiBaddLink|. + Remap command: `VimwikiBaddLink` + *vimwiki_* *vimwiki_* , n Follow wiki link (create target wiki page if needed), opening in a new tab. @@ -796,6 +803,10 @@ Vimwiki file. If 'move_cursor' is given and nonzero, the cursor moves to the window with the opened link, otherwise, it stays in the window with the link. +*:VimwikiBaddLink* + Add to the buffer list, without loading, if it wasn't listed yet (create + target wiki page if needed). + *:VimwikiTabnewLink* Follow wiki link in a new tab (create target wiki page if needed). @@ -3958,6 +3969,7 @@ Contributors and their Github usernames in roughly chronological order: - Vinny Furia (@vinnyfuria) - paperbenni (@paperbenni) - Lily Foster (@lilyinstarlight) + - Jean-Luc Bastarache (@jlbas) - Youssof Taha (@ysftaha) - Thomas Leyh (@leyhline) @@ -4019,6 +4031,8 @@ New:~ alternative date string format * Feature: Add |VimwikiPasteLink| to paste an absolute wiki link to the current file + * Feature: Add |VimwikiBaddLink| to add links to the buffer list, without + loading, if they weren't listed yet Changed:~ * PR #1047: Allow to replace default mapping of VimwikiToggleListItem diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 35ffc45..04af334 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -306,6 +306,7 @@ command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1 command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link() command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', ) command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', ) +command! -buffer VimwikiBaddLink call vimwiki#base#follow_link('badd', 0, 1) command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link() @@ -386,6 +387,7 @@ if str2nr(vimwiki#vars#get_global('key_mappings').mouse) \ :call vimwiki#base#follow_link('nosplit', 0, 1, "\2-LeftMouse>") nnoremap :VimwikiSplitLink nnoremap :VimwikiVSplitLink + nnoremap :VimwikiBaddLink nnoremap :VimwikiGoBackLink endif @@ -406,6 +408,8 @@ nnoremap