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