lmburns / link-visitor.nvim

Let me help you open the links!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

link-visitor

Let me help you open the links!

link-visitor-demo

Installation

xiyaowong/link-visitor.nvim

Same as other normal plugins, use your favourite plugin manager to install.

Setup

require("link-visitor").setup({
  open_cmd = nil,
  --[[ cmd to open url
    defaults:
    win or wsl: cmd.exe /c start
    mac: open
    linux: xdg-open
  --]]
  silent = true, -- disable all prints, `false` by defaultsskip_confirmation
  skip_confirmation = false, -- Skip the confirmation step, default: false
})

API

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.visit(url) -- Open the url

Commands

  • VisitLinkInBuffer - Open links in the buffer
  • VisitLinkUnderCursor - Open link under the cursor
  • VisitLinkNearCursor - Open link near the cursor

Example

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

About

Let me help you open the links!


Languages

Language:Lua 100.0%