From aa53cd47c45ad4a087a35ab9150807d1dfef65ed Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 7 Nov 2024 16:21:48 +0100 Subject: [PATCH] feat(keymaps): only add lazygit keymaps when available. Closes #4643. Closes #4247 --- lua/lazyvim/config/keymaps.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 422cadd2..c4160bef 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -132,13 +132,15 @@ if vim.lsp.inlay_hint then end -- lazygit -map("n", "gg", function() Snacks.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) -map("n", "gG", function() Snacks.lazygit() end, { desc = "Lazygit (cwd)" }) -map("n", "gb", function() Snacks.git.blame_line() end, { desc = "Git Blame Line" }) -map("n", "gB", function() Snacks.gitbrowse() end, { desc = "Git Browse" }) -map("n", "gf", function() Snacks.lazygit.log_file() end, { desc = "Lazygit Current File History" }) -map("n", "gl", function() Snacks.lazygit.log({ cwd = LazyVim.root.git() }) end, { desc = "Lazygit Log" }) -map("n", "gL", function() Snacks.lazygit.log() end, { desc = "Lazygit Log (cwd)" }) +if vim.fn.executable("lazygit") == 1 then + map("n", "gg", function() Snacks.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) + map("n", "gG", function() Snacks.lazygit() end, { desc = "Lazygit (cwd)" }) + map("n", "gb", function() Snacks.git.blame_line() end, { desc = "Git Blame Line" }) + map("n", "gB", function() Snacks.gitbrowse() end, { desc = "Git Browse" }) + map("n", "gf", function() Snacks.lazygit.log_file() end, { desc = "Lazygit Current File History" }) + map("n", "gl", function() Snacks.lazygit.log({ cwd = LazyVim.root.git() }) end, { desc = "Lazygit Log" }) + map("n", "gL", function() Snacks.lazygit.log() end, { desc = "Lazygit Log (cwd)" }) +end -- quit map("n", "qq", "qa", { desc = "Quit All" })