diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua index fed140c..ff94056 100644 --- a/lua/lazy/util.lua +++ b/lua/lazy/util.lua @@ -25,30 +25,15 @@ function M.open(uri, opts) if not opts.system and M.file_exists(uri) then return M.float({ style = "", file = uri }) end - local Config = require("lazy.core.config") - local cmd - if not opts.system and Config.options.ui.browser then - cmd = { Config.options.ui.browser, uri } - elseif vim.fn.has("win32") == 1 then - cmd = { "explorer", uri } - elseif vim.fn.has("macunix") == 1 then - cmd = { "open", uri } - else - if vim.fn.executable("xdg-open") == 1 then - cmd = { "xdg-open", uri } - elseif vim.fn.executable("wslview") == 1 then - cmd = { "wslview", uri } - else - cmd = { "open", uri } - end + local cmd, err = vim.ui.open(uri) + if cmd then + cmd:wait() end - - local ret = vim.fn.jobstart(cmd, { detach = true }) - if ret <= 0 then + if err then local msg = { "Failed to open uri", - ret, - vim.inspect(cmd), + err, + vim.inspect(uri), } vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR) end