feat(client): add Vim split/tab/back link-follow commands + true tab-drop

The plain-Vim client only defined VimwikiFollowLink; the split/vsplit/
tabnew/tabdrop/back command surface existed only in the Neovim branch.
Add :Vimwiki{Split,VSplit,Tabnew,TabDrop,GoBack}Link (+ :Nuwiki* aliases)
to the Vim branch, backed by a new nuwiki#commands#follow_link_drop()
helper that runs `:tab drop` to reuse an already-open tab.

Both clients now implement real tab-drop: open_uri gains a 'tabdrop'
case and M.follow_link_drop(); the Neovim TabDropLink commands and the
<C-S-CR> mappings (Vim + Lua) are repointed off the old tabnew cheat.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 07:54:20 -03:00
parent 00a671e486
commit f65d861f72
4 changed files with 86 additions and 5 deletions
+41
View File
@@ -188,6 +188,47 @@ function! s:badd_from_response(notification) abort
echom 'nuwiki: added ' . l:path
endfunction
" `:VimwikiTabDropLink` — open the link target in a tab, reusing an
" existing tab/window if the file is already shown (`:tab drop`). Routes
" through vim-lsp's textDocument/definition like `badd_link`.
function! nuwiki#commands#follow_link_drop() abort
if s:has_vimlsp()
call lsp#send_request(s:server, {
\ 'method': 'textDocument/definition',
\ 'params': s:cursor_position(),
\ 'on_notification': function('s:drop_from_response'),
\ })
return
endif
if s:has_coc()
let l:locs = CocAction('getDefinition')
if type(l:locs) == type([]) && !empty(l:locs)
let l:uri = get(l:locs[0], 'uri', get(l:locs[0], 'targetUri', ''))
if !empty(l:uri)
let l:path = substitute(l:uri, '^file://', '', '')
execute 'tab drop ' . fnameescape(l:path)
endif
endif
return
endif
echohl ErrorMsg | echom 'nuwiki: no supported LSP client for follow_link_drop' | echohl None
endfunction
function! s:drop_from_response(notification) abort
let l:result = get(get(a:notification, 'response', {}), 'result', {})
let l:uri = ''
if type(l:result) == type({})
let l:uri = get(l:result, 'uri', get(l:result, 'targetUri', ''))
elseif type(l:result) == type([]) && !empty(l:result)
let l:uri = get(l:result[0], 'uri', get(l:result[0], 'targetUri', ''))
endif
if l:uri ==# ''
return
endif
let l:path = substitute(l:uri, '^file://', '', '')
execute 'tab drop ' . fnameescape(l:path)
endfunction
" ===== Smart <CR>: follow or wrap-then-follow =====
function! s:cursor_inside_wikilink() abort