mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-07 00:06:34 +00:00
Merge f6090f634d
into 6c3bda4aca
This commit is contained in:
commit
1b2a078890
1 changed files with 41 additions and 25 deletions
|
@ -25,6 +25,20 @@ 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
|
||||||
|
if vim.fn.has('nvim-0.10.0') == 1 then
|
||||||
|
local cmd, err = vim.ui.open(uri)
|
||||||
|
if cmd then
|
||||||
|
cmd:wait()
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
local msg = {
|
||||||
|
"Failed to open uri",
|
||||||
|
err,
|
||||||
|
vim.inspect(uri),
|
||||||
|
}
|
||||||
|
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
else
|
||||||
local Config = require("lazy.core.config")
|
local Config = require("lazy.core.config")
|
||||||
local cmd
|
local cmd
|
||||||
if not opts.system and Config.options.ui.browser then
|
if not opts.system and Config.options.ui.browser then
|
||||||
|
@ -38,11 +52,12 @@ function M.open(uri, opts)
|
||||||
cmd = { "xdg-open", uri }
|
cmd = { "xdg-open", uri }
|
||||||
elseif vim.fn.executable("wslview") == 1 then
|
elseif vim.fn.executable("wslview") == 1 then
|
||||||
cmd = { "wslview", uri }
|
cmd = { "wslview", uri }
|
||||||
|
elseif vim.fn.executable("explorer.exe") == 1 then
|
||||||
|
cmd = { "explorer.exe", uri }
|
||||||
else
|
else
|
||||||
cmd = { "open", uri }
|
cmd = { "open", uri }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ret = vim.fn.jobstart(cmd, { detach = true })
|
local ret = vim.fn.jobstart(cmd, { detach = true })
|
||||||
if ret <= 0 then
|
if ret <= 0 then
|
||||||
local msg = {
|
local msg = {
|
||||||
|
@ -52,6 +67,7 @@ function M.open(uri, opts)
|
||||||
}
|
}
|
||||||
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
|
vim.notify(table.concat(msg, "\n"), vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.read_file(file)
|
function M.read_file(file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue