chore: use vim.ui.open if it's available

This commit is contained in:
Micah Halter
2023-07-06 15:29:37 -04:00
parent 31fbc64551
commit f66a31a83d
3 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -26,11 +26,12 @@ maps.n["k"] = { "v:count == 0 ? 'gk' : 'k'", expr = true, desc = "Move cursor up
maps.n["<leader>w"] = { "<cmd>w<cr>", desc = "Save" }
maps.n["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" }
maps.n["<leader>n"] = { "<cmd>enew<cr>", desc = "New File" }
maps.n["gx"] = { utils.system_open, desc = "Open the file under cursor with system app" }
maps.n["<C-s>"] = { "<cmd>w!<cr>", desc = "Force write" }
maps.n["<C-q>"] = { "<cmd>q!<cr>", desc = "Force quit" }
maps.n["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" }
maps.n["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" }
-- TODO: Remove when dropping support for <Neovim v0.10
if not vim.ui.open then maps.n["gx"] = { utils.system_open, desc = "Open the file under cursor with system app" } end
-- Plugin Manager
maps.n["<leader>p"] = sections.p
+2
View File
@@ -162,6 +162,8 @@ end
--- Open a URL under the cursor with the current operating system
---@param path string The path of the file to open with the system opener
function M.system_open(path)
-- TODO: REMOVE WHEN DROPPING NEOVIM <0.10
if vim.ui.open then return vim.ui.open(path) end
local cmd
if vim.fn.has "win32" == 1 and vim.fn.executable "explorer" == 1 then
cmd = { "cmd.exe", "/K", "explorer" }
+4 -1
View File
@@ -45,7 +45,10 @@ return {
},
},
commands = {
system_open = function(state) require("astronvim.utils").system_open(state.tree:get_node():get_id()) end,
system_open = function(state)
-- TODO: just use vim.ui.open when dropping support for Neovim <0.10
(vim.ui.open or require("astronvim.utils").system_open)(state.tree:get_node():get_id())
end,
parent_or_close = function(state)
local node = state.tree:get_node()
if (node.type == "directory" or node:has_children()) and node:is_expanded() then