Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xiyaowong/link-visitor.nvim
Let me help you open the links!
https://github.com/xiyaowong/link-visitor.nvim
neovim nvim
Last synced: 12 days ago
JSON representation
Let me help you open the links!
- Host: GitHub
- URL: https://github.com/xiyaowong/link-visitor.nvim
- Owner: xiyaowong
- Created: 2022-07-02T12:27:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-30T07:28:43.000Z (11 months ago)
- Last Synced: 2024-10-12T22:53:12.131Z (27 days ago)
- Topics: neovim, nvim
- Language: Lua
- Homepage:
- Size: 15.6 KB
- Stars: 47
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-neovim - xiyaowong/link-visitor.nvim - Let me help you open the links. (Utility / Cursorline)
README
# link-visitor
Let me help you open the links!
![link-visitor-demo](https://user-images.githubusercontent.com/47070852/177006635-ed9ff276-8f3d-4c42-9f94-2f6356e34eb2.gif)
## Installation
`xiyaowong/link-visitor.nvim`
Same as other normal plugins, use your favourite plugin manager to install.
## Setup
```lua
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()`
})
```## API
```lua
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
```## Commands
- `VisitLinkInBuffer` - Open links in the buffer
- `VisitLinkUnderCursor` - Open link under the cursor
- `VisitLinkNearCursor` - Open link near the cursor
- `VisitLinkNearest` - Open the nearest link to the current position## Highlight Groups
- `LinkVisitorFloat` - Background of popup. (default: links to `NormalFloat`)
- `LinkVisitorBorder` - Border of popup. (default: links to `FloatBorder`)
- `LinkVisitorText` - Text displayed in popup. (default: links to `MoreMsg`)## 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`
```lua
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