mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Just use vim.ui.open or throw error if doesn't exist
This commit is contained in:
parent
703f01a3c2
commit
184807bef2
1 changed files with 3 additions and 18 deletions
|
|
@ -71,29 +71,14 @@ return {
|
||||||
},
|
},
|
||||||
["O"] = {
|
["O"] = {
|
||||||
command = function(state)
|
command = function(state)
|
||||||
local function open_file(filepath)
|
|
||||||
if vim.fn.has("mac") == 1 then
|
|
||||||
os.execute("open " .. string.format("'%s'", filepath))
|
|
||||||
elseif vim.fn.has("win32") == 1 then
|
|
||||||
if vim.fn.executable("rundll32") == 1 then
|
|
||||||
os.execute("rundll32 " .. string.format("'%s'", filepath))
|
|
||||||
end
|
|
||||||
elseif vim.fn.executable("wslview") == 1 then
|
|
||||||
os.execute("wslview " .. string.format("'%s'", filepath))
|
|
||||||
elseif vim.fn.executable("xdg-open") == 1 then
|
|
||||||
os.execute("xdg-open " .. string.format("'%s'", filepath))
|
|
||||||
else
|
|
||||||
vim.notify("neo-tree: OS not detected", "error")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local filepath = state.tree:get_node().path
|
|
||||||
if vim.ui.open then
|
if vim.ui.open then
|
||||||
|
local filepath = state.tree:get_node().path
|
||||||
vim.ui.open(filepath)
|
vim.ui.open(filepath)
|
||||||
else
|
else
|
||||||
open_file(filepath)
|
require("lazyvim.util").error("vim.ui.open is not available")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
desc = "open_with_system_defaults",
|
desc = "open_with_system_default",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue