Skip to content

Commit c546b12

Browse files
committed
fix: use vim.ui.open to open uri
fixes folke#1947
1 parent 6c3bda4 commit c546b12

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

lua/lazy/util.lua

+6-21
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,15 @@ function M.open(uri, opts)
2525
if not opts.system and M.file_exists(uri) then
2626
return M.float({ style = "", file = uri })
2727
end
28-
local Config = require("lazy.core.config")
29-
local cmd
30-
if not opts.system and Config.options.ui.browser then
31-
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
35-
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 }
41-
else
42-
cmd = { "open", uri }
43-
end
28+
local cmd, err = vim.ui.open(uri)
29+
if cmd then
30+
cmd:wait()
4431
end
45-
46-
local ret = vim.fn.jobstart(cmd, { detach = true })
47-
if ret <= 0 then
32+
if err then
4833
local msg = {
4934
"Failed to open uri",
50-
ret,
51-
vim.inspect(cmd),
35+
err,
36+
vim.inspect(uri),
5237
}
5338
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
5439
end

0 commit comments

Comments
 (0)