mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat(neo-tree): add OS checks for system default open commands
This commit is contained in:
parent
9b86dca4ee
commit
051212f2b1
1 changed files with 17 additions and 2 deletions
|
|
@ -72,8 +72,23 @@ return {
|
||||||
["O"] = {
|
["O"] = {
|
||||||
command = function(state)
|
command = function(state)
|
||||||
local filepath = state.tree:get_node().path
|
local filepath = state.tree:get_node().path
|
||||||
|
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
|
||||||
|
os.execute("wslview " .. string.format("'%s'", filepath))
|
||||||
|
elseif is_linux then
|
||||||
|
os.execute("xdg-open " .. string.format("'%s'", filepath))
|
||||||
|
elseif is_windows then
|
||||||
|
os.execute("start " .. string.format("'%s'", filepath))
|
||||||
|
else
|
||||||
|
vim.notify("neo-tree: OS not detected", "error")
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
desc = "open_with_system_defaults",
|
desc = "open_with_system_defaults",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue