You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
502 B

4 days ago
local get_url = function()
local line = vim.api.nvim_get_current_line()
local window = vim.api.nvim_get_current_win()
local _,col = unpack(vim.api.nvim_win_get_cursor(window))
local urls = line:gmatch("%w+://[%w_%.%-]+[%w_.@~%-%/%?&#=]*")
for url in urls do
if col >= string.find(line, url) and col <= string.find(line, url) + #url then
return url
end
end
end
local M = {}
M.open_url = function()
local url = get_url()
if url then vim.ui.open(url) end
end
return M