From c87224f2f63dc6c0036d8ccafd79f8b3ccfbb7da Mon Sep 17 00:00:00 2001 From: Alan-John-Byrne Date: Fri, 2 Aug 2024 22:46:31 +0100 Subject: [PATCH] Switched to less invasive vim.fn.executable solution --- lua/lazyvim/config/keymaps.lua | 12 +----------- lua/lazyvim/util/gitcheck.lua | 12 ------------ 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 lua/lazyvim/util/gitcheck.lua diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index bda99f9e..bfb11147 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -130,13 +130,7 @@ if vim.lsp.inlay_hint then end -- lazygit -local status, gitcheck = pcall(require, "lazyvim.util.gitcheck") -if not status then - print("Failed to load gitcheck.") -else - local is_lazygit_available = gitcheck.is_lazygit_available --- Setting keymaps only if the user has it installed: -if is_lazygit_available() then +if vim.fn.executable('lazygit') == 1 then map("n", "gg", function() LazyVim.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) map("n", "gG", function() LazyVim.lazygit() end, { desc = "Lazygit (cwd)" }) map("n", "gb", LazyVim.lazygit.blame_line, { desc = "Git Blame Line" }) @@ -151,11 +145,7 @@ end, { desc = "Lazygit Log" }) map("n", "gL", function() LazyVim.lazygit({ args = { "log" } }) end, { desc = "Lazygit Log (cwd)" }) -else - print("Lazygit is not installed.") end -end - -- quit map("n", "qq", "qa", { desc = "Quit All" }) diff --git a/lua/lazyvim/util/gitcheck.lua b/lua/lazyvim/util/gitcheck.lua deleted file mode 100644 index fae563ff..00000000 --- a/lua/lazyvim/util/gitcheck.lua +++ /dev/null @@ -1,12 +0,0 @@ --- Simple check to see if the user has lazygit installed. Only then use keymaps. -gitcheck = {} -function gitcheck.is_lazygit_available() - local handle = io.popen("lazygit --version") - if handle then - local result = handle:read("*a") - handle:close() - return result ~= "" - end - return false -end -return gitcheck \ No newline at end of file