Make "O" undefined mapping if vim.ui.open isn't available

This commit is contained in:
Uthman Mohamed 2024-03-22 18:17:55 -04:00
parent 184807bef2
commit e91fa6eaf5

View file

@ -69,17 +69,16 @@ return {
end, end,
desc = "copy path to clipboard", desc = "copy path to clipboard",
}, },
["O"] = { ["O"] = vim.ui.open and {
command = function(state) function(state)
if vim.ui.open then local path = state.tree:get_node().path
local filepath = state.tree:get_node().path local ret = vim.ui.open(path)
vim.ui.open(filepath) if ret and ret.code ~= 0 then
else require("lazyvim.util").error("Failed to open file: " .. ret.stderr .. "\n .. " .. ret.stdout)
require("lazyvim.util").error("vim.ui.open is not available")
end end
end, end,
desc = "open_with_system_default", desc = "open with system default application",
}, } or nil,
}, },
}, },
default_component_configs = { default_component_configs = {