Let me help you open the links!
xiyaowong/link-visitor.nvim
Same as other normal plugins, use your favourite plugin manager to install.
require("link-visitor").setup({
open_cmd = nil,
--[[
1. cmd to open url
defaults:
win or wsl: cmd.exe /c start
mac: open
linux: xdg-open
2. a function to handle the link
the function signature: func(link: string)
--]]
silent = true, -- disable all prints, `false` by defaults skip_confirmation
skip_confirmation = false, -- Skip the confirmation step, default: false
border = "rounded" -- none, single, double, rounded, solid, shadow see `:h nvim_open_win()`
})
local lv = require 'link-visitor'
lv.links_in_buffer(bufnr?) -- Open links in the buffer, current buffer by default
lv.link_under_cursor() -- Open link under the cursor(search in current line)
lv.link_near_cursor() -- Open link near the cursor(search in current line)
lv.link_nearest() -- Open the nearest link to the current position(Search in the whole buffer)
lv.visit(url) -- Open the url
VisitLinkInBuffer
- Open links in the bufferVisitLinkUnderCursor
- Open link under the cursorVisitLinkNearCursor
- Open link near the cursorVisitLinkNearest
- Open the nearest link to the current position
LinkVisitorFloat
- Background of popup. (default: links toNormalFloat
)LinkVisitorBorder
- Border of popup. (default: links toFloatBorder
)LinkVisitorText
- Text displayed in popup. (default: links toMoreMsg
)
This plugin is useful for lsp-hover documentation
After entering the float window, use K
to open link under the cursor,
L
to open link near the cursor
coc.nvim
vim.api.nvim_create_autocmd("User", {
callback = function()
local ok, buf = pcall(vim.api.nvim_win_get_buf, vim.g.coc_last_float_win)
if ok then
vim.keymap.set("n", "K", function()
require("link-visitor").link_under_cursor()
end, { buffer = buf })
vim.keymap.set("n", "L", function()
require("link-visitor").link_near_cursor()
end, { buffer = buf })
end
end,
pattern = "CocOpenFloat",
})
native-lsp
TODO