From e346d17812de516ad0789ede49b49a8b7ba213fe Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 19 May 2024 09:29:15 +0200 Subject: [PATCH] fix(gitui): properly delete lazygit keymap at the correct time. Fixes #3227 --- lua/lazyvim/plugins/extras/util/gitui.lua | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lua/lazyvim/plugins/extras/util/gitui.lua b/lua/lazyvim/plugins/extras/util/gitui.lua index ad044cd8..d78c4f81 100644 --- a/lua/lazyvim/plugins/extras/util/gitui.lua +++ b/lua/lazyvim/plugins/extras/util/gitui.lua @@ -4,22 +4,34 @@ return { { "williamboman/mason.nvim", keys = { - { "gG", + { + "gG", function() LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false }) end, - desc = "GitUi (cwd)" }, - { "gg", + desc = "GitUi (cwd)", + }, + { + "gg", function() LazyVim.terminal.open({ "gitui" }, { cwd = LazyVim.root.get(), esc_esc = false, ctrl_hjkl = false }) end, - desc = "GitUi (Root Dir)" } + desc = "GitUi (Root Dir)", + }, }, + init = function() + -- delete lazygit keymap for file history + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimKeymaps", + once = true, + callback = function() + pcall(vim.keymap.del, "n", "gf") + end, + }) + end, opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} vim.list_extend(opts.ensure_installed, { "gitui" }) - -- delete lazygit keymap for file history - vim.keymap.del("n", "gf") end, }, }