feat(ui): gx: use url extmark attribute and tree-sitter directive (#30192)

Use the "url" extmark attribute as well as the "url" tree-sitter
metadata key to determine if the cursor is over something Nvim considers
a URL.
This commit is contained in:
Gregory Anders
2024-08-31 19:56:20 -05:00
committed by GitHub
parent 808d73b5df
commit 9762c5e340
2 changed files with 58 additions and 22 deletions

View File

@@ -113,9 +113,11 @@ do
local gx_desc =
'Opens filepath or URI under cursor with the system handler (file explorer, web browser, …)'
vim.keymap.set({ 'n' }, 'gx', function()
local err = do_open(require('vim.ui')._get_url())
if err then
vim.notify(err, vim.log.levels.ERROR)
for _, url in ipairs(require('vim.ui')._get_urls()) do
local err = do_open(url)
if err then
vim.notify(err, vim.log.levels.ERROR)
end
end
end, { desc = gx_desc })
vim.keymap.set({ 'x' }, 'gx', function()