This commit is contained in:
Guilherme Soares 2024-11-10 16:24:31 +00:00 committed by GitHub
commit d4bc55ca25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 9 deletions

View File

@ -29,18 +29,26 @@ function M.open(uri, opts)
local cmd local cmd
if not opts.system and Config.options.ui.browser then if not opts.system and Config.options.ui.browser then
cmd = { Config.options.ui.browser, uri } cmd = { Config.options.ui.browser, uri }
elseif vim.fn.has("win32") == 1 then elseif vim.fn.has("mac") == 1 then
cmd = { "explorer", uri }
elseif vim.fn.has("macunix") == 1 then
cmd = { "open", uri } cmd = { "open", uri }
else elseif vim.fn.has("win32") == 1 then
if vim.fn.executable("xdg-open") == 1 then if vim.fn.executable("rundll32") == 1 then
cmd = { "xdg-open", uri } cmd = { "rundll32", "url.dll,FileProtocolHandler", uri }
elseif vim.fn.executable("wslview") == 1 then
cmd = { "wslview", uri }
else else
cmd = { "open", uri } vim.notify("rundll32 not found", vim.log.levels.ERROR)
return
end end
elseif vim.fn.executable("xdg-open") == 1 then
cmd = { "xdg-open", uri }
elseif vim.fn.executable("wslview") == 1 then
cmd = { "wslview", uri }
elseif vim.fn.executable("explorer.exe") == 1 then
cmd = { "explorer.exe", uri }
elseif vim.fn.executable("lemonade") == 1 then
cmd = { "lemonade", "open", uri }
else
vim.notify("no handler found (tried: wslview, explorer.exe, xdg-open, lemonade)", vim.log.levels.ERROR)
return
end end
local ret = vim.fn.jobstart(cmd, { detach = true }) local ret = vim.fn.jobstart(cmd, { detach = true })