mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-11 09:52:31 +00:00
parent
6c3bda4aca
commit
c546b12fff
1 changed files with 6 additions and 21 deletions
|
@ -25,30 +25,15 @@ function M.open(uri, opts)
|
||||||
if not opts.system and M.file_exists(uri) then
|
if not opts.system and M.file_exists(uri) then
|
||||||
return M.float({ style = "", file = uri })
|
return M.float({ style = "", file = uri })
|
||||||
end
|
end
|
||||||
local Config = require("lazy.core.config")
|
local cmd, err = vim.ui.open(uri)
|
||||||
local cmd
|
if cmd then
|
||||||
if not opts.system and Config.options.ui.browser then
|
cmd:wait()
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
if err then
|
||||||
local ret = vim.fn.jobstart(cmd, { detach = true })
|
|
||||||
if ret <= 0 then
|
|
||||||
local msg = {
|
local msg = {
|
||||||
"Failed to open uri",
|
"Failed to open uri",
|
||||||
ret,
|
err,
|
||||||
vim.inspect(cmd),
|
vim.inspect(uri),
|
||||||
}
|
}
|
||||||
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
|
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue