Skip to content

Commit 5110f1d

Browse files
committed
feat: add more handlers to util.open
1 parent 1159bdc commit 5110f1d

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

lua/lazy/util.lua

+17-9
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,26 @@ function M.open(uri, opts)
2929
local cmd
3030
if not opts.system and Config.options.ui.browser then
3131
cmd = { Config.options.ui.browser, uri }
32-
elseif vim.fn.has("win32") == 1 then
33-
cmd = { "explorer", uri }
34-
elseif vim.fn.has("macunix") == 1 then
32+
elseif vim.fn.has("mac") == 1 then
3533
cmd = { "open", uri }
36-
else
37-
if vim.fn.executable("xdg-open") == 1 then
38-
cmd = { "xdg-open", uri }
39-
elseif vim.fn.executable("wslview") == 1 then
40-
cmd = { "wslview", uri }
34+
elseif vim.fn.has("win32") == 1 then
35+
if vim.fn.executable("rundll32") == 1 then
36+
cmd = { "rundll32", "url.dll,FileProtocolHandler", uri }
4137
else
42-
cmd = { "open", uri }
38+
vim.notify("rundll32 not found", vim.log.levels.ERROR)
39+
return
4340
end
41+
elseif vim.fn.executable("xdg-open") == 1 then
42+
cmd = { "xdg-open", uri }
43+
elseif vim.fn.executable("wslview") == 1 then
44+
cmd = { "wslview", uri }
45+
elseif vim.fn.executable("explorer.exe") == 1 then
46+
cmd = { "explorer.exe", uri }
47+
elseif vim.fn.executable("lemonade") == 1 then
48+
cmd = { "lemonade", "open", uri }
49+
else
50+
vim.notify("no handler found (tried: wslview, explorer.exe, xdg-open, lemonade)", vim.log.levels.ERROR)
51+
return
4452
end
4553

4654
local ret = vim.fn.jobstart(cmd, { detach = true })

0 commit comments

Comments
 (0)