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
+30
View File
@@ -73,6 +73,10 @@ local function open_uri(uri, tab)
return
end
local path = vim.uri_to_fname(uri)
if tab == 'tabdrop' then
vim.cmd('tab drop ' .. vim.fn.fnameescape(path))
return
end
local cmd
if tab == 'split' then
cmd = 'split'
@@ -206,6 +210,32 @@ function M.badd_link()
end
end
--- `:VimwikiTabDropLink` — open the link target in a tab, reusing an
--- existing tab/window if the file is already shown (`:tab drop`). Uses
--- the LSP definition response to resolve the target file.
function M.follow_link_drop()
local client = find_client()
if not client then
vim.notify('nuwiki: language server not attached', vim.log.levels.ERROR)
return
end
local params = position_params(client)
params.textDocument = { uri = buf_uri() }
local req = client.request
local handler = function(_, result)
local loc
if type(result) == 'table' then
loc = result[1] or result
end
local uri = type(loc) == 'table' and (loc.uri or loc.targetUri) or nil
open_uri(uri, 'tabdrop')
end
local bufnr = vim.api.nvim_get_current_buf()
if type(req) == 'function' then
client:request('textDocument/definition', params, handler, bufnr)
end
end
function M.follow_link_or_create()
if cursor_inside_wikilink() then
vim.lsp.buf.definition()