From 184807bef26215f868d264f613fdc76e97b46d8f Mon Sep 17 00:00:00 2001 From: Uthman Mohamed <83053931+1239uth@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:40:19 -0400 Subject: [PATCH] Just use vim.ui.open or throw error if doesn't exist --- lua/lazyvim/plugins/editor.lua | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index c0c36af8..0c225829 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -71,29 +71,14 @@ return { }, ["O"] = { 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 + local filepath = state.tree:get_node().path vim.ui.open(filepath) else - open_file(filepath) + require("lazyvim.util").error("vim.ui.open is not available") end end, - desc = "open_with_system_defaults", + desc = "open_with_system_default", }, }, },