Remove the user-mappable function and use commands instead.
This commit is contained in:
parent
50c95f1bef
commit
786aa470e3
@ -1101,8 +1101,10 @@ function! vimwiki#base#find_prev_link()
|
||||
endfunction
|
||||
|
||||
|
||||
" This is an API function, that is, remappable by the user. Don't change the signature.
|
||||
function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
|
||||
function! vimwiki#base#follow_link(split, ...)
|
||||
let reuse_other_split_window = a:0 >= 1 ? a:1 : 0
|
||||
let move_cursor_to_new_window = a:0 >= 2 ? a:2 : 1
|
||||
|
||||
" Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
|
||||
" default open_link handler
|
||||
|
||||
@ -1138,7 +1140,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
|
||||
|
||||
" if we want to and can reuse a split window, jump to that window and open
|
||||
" the new file there
|
||||
if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && a:reuse
|
||||
if (a:split ==# 'hsplit' || a:split ==# 'vsplit') && reuse_other_split_window
|
||||
let previous_window_nr = winnr('#')
|
||||
if previous_window_nr > 0 && previous_window_nr != winnr()
|
||||
execute previous_window_nr . 'wincmd w'
|
||||
@ -1162,7 +1164,7 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
|
||||
|
||||
call vimwiki#base#open_link(cmd, lnk)
|
||||
|
||||
if !a:move_cursor
|
||||
if !move_cursor_to_new_window
|
||||
if (a:split ==# 'hsplit' || a:split ==# 'vsplit')
|
||||
execute 'wincmd p'
|
||||
elseif a:split ==# 'tab'
|
||||
@ -1171,8 +1173,8 @@ function! vimwiki#base#follow_link(split, reuse, move_cursor, ...)
|
||||
endif
|
||||
|
||||
else
|
||||
if a:0 > 0
|
||||
execute "normal! ".a:1
|
||||
if a:0 >= 3
|
||||
execute "normal! ".a:3
|
||||
else
|
||||
call vimwiki#base#normalize_link(0)
|
||||
endif
|
||||
|
@ -677,12 +677,24 @@ Vimwiki file.
|
||||
*:VimwikiGoBackLink*
|
||||
Go back to the wiki page you came from.
|
||||
|
||||
*:VimwikiSplitLink*
|
||||
*:VimwikiSplitLink* [reuse] [move_cursor]
|
||||
Split and follow wiki link (create target wiki page if needed).
|
||||
|
||||
*:VimwikiVSplitLink*
|
||||
If the argument 'reuse' is given and nonzero, the link is opened in a
|
||||
possibly existing split window instead of making a new split.
|
||||
|
||||
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.
|
||||
|
||||
*:VimwikiVSplitLink* [reuse] [move_cursor]
|
||||
Vertical split and follow wiki link (create target wiki page if needed).
|
||||
|
||||
If the argument 'reuse' is given and nonzero, the link is opened in a
|
||||
possibly existing split window instead of making a new split.
|
||||
|
||||
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.
|
||||
|
||||
*:VimwikiTabnewLink*
|
||||
Follow wiki link in a new tab (create target wiki page if needed).
|
||||
|
||||
@ -829,35 +841,6 @@ Vimwiki file.
|
||||
are specified, outputs all tags. To make this command work properly, make
|
||||
sure the tags have been built (see |vimwiki-build-tags|).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
4.3. Functions *vimwiki-functions*
|
||||
|
||||
Functions to interact with Vimwiki. (It's intended that most commands will be
|
||||
replaced with corresponding function calls in the future.)
|
||||
Warning: this is currently unstable and likely to change.
|
||||
|
||||
|
||||
To map them to a key, use >
|
||||
nnoremap <C-K> :call vimwiki#base#function_name(arg1, arg2)<CR>
|
||||
<
|
||||
|
||||
*vimwiki-follow_link*
|
||||
vimwiki#base#follow_link({split}, {reuse}, {move_cursor})
|
||||
Open the link under the cursor. {split} can have the following values:
|
||||
'nosplit' open the link in the current window
|
||||
'vsplit' open in a vertically split window
|
||||
'hsplit' open in a horizontally split window
|
||||
'tab' open in a new tab
|
||||
|
||||
If {reuse} is 1 and {split} one of 'vsplit' or 'hsplit', open the link in
|
||||
a possibly existing split window instead of making a new split.
|
||||
|
||||
If {move_cursor} is 1 the cursor moves to the window or tab with the
|
||||
opened link, otherwise, it stays in the window or tab with the link.
|
||||
|
||||
For example, <CR> is per default mapped to
|
||||
vimwiki#base#follow_link('nosplit', 0, 1)
|
||||
|
||||
|
||||
==============================================================================
|
||||
5. Wiki syntax *vimwiki-syntax*
|
||||
|
@ -259,8 +259,8 @@ command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
|
||||
command! -buffer VimwikiRenameLink call vimwiki#base#rename_link()
|
||||
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit', 0, 1)
|
||||
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
|
||||
command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('hsplit', 0, 1)
|
||||
command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', 0, 1)
|
||||
command! -buffer -nargs=* VimwikiSplitLink call vimwiki#base#follow_link('hsplit', <f-args>)
|
||||
command! -buffer -nargs=* VimwikiVSplitLink call vimwiki#base#follow_link('vsplit', <f-args>)
|
||||
|
||||
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user