mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
update OS checks
This commit is contained in:
parent
e09e27b7f0
commit
703f01a3c2
1 changed files with 16 additions and 19 deletions
|
|
@ -71,30 +71,27 @@ return {
|
||||||
},
|
},
|
||||||
["O"] = {
|
["O"] = {
|
||||||
command = function(state)
|
command = function(state)
|
||||||
local filepath = state.tree:get_node().path
|
local function open_file(filepath)
|
||||||
|
if vim.fn.has("mac") == 1 then
|
||||||
if vim.ui.open then
|
|
||||||
vim.ui.open(filepath)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local uname = vim.loop.os_uname()
|
|
||||||
local OS = uname.sysname
|
|
||||||
local is_mac = OS == "Darwin"
|
|
||||||
local is_linux = OS == "Linux"
|
|
||||||
local is_windows = OS:find("Windows") and true or false
|
|
||||||
local is_wsl = is_linux and uname.release:lower():find("microsoft") and true or false
|
|
||||||
if is_mac then
|
|
||||||
os.execute("open " .. string.format("'%s'", filepath))
|
os.execute("open " .. string.format("'%s'", filepath))
|
||||||
elseif is_wsl then
|
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))
|
os.execute("wslview " .. string.format("'%s'", filepath))
|
||||||
elseif is_linux then
|
elseif vim.fn.executable("xdg-open") == 1 then
|
||||||
os.execute("xdg-open " .. string.format("'%s'", filepath))
|
os.execute("xdg-open " .. string.format("'%s'", filepath))
|
||||||
elseif is_windows then
|
|
||||||
os.execute("start " .. string.format("'%s'", filepath))
|
|
||||||
else
|
else
|
||||||
vim.notify("neo-tree: OS not detected", "error")
|
vim.notify("neo-tree: OS not detected", "error")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
local filepath = state.tree:get_node().path
|
||||||
|
if vim.ui.open then
|
||||||
|
vim.ui.open(filepath)
|
||||||
|
else
|
||||||
|
open_file(filepath)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
desc = "open_with_system_defaults",
|
desc = "open_with_system_defaults",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue