From 09ca10511726876efcf9269adb739454a4f4625c Mon Sep 17 00:00:00 2001 From: Patrick Pagni Date: Thu, 4 Jun 2026 16:42:20 +0100 Subject: [PATCH] feat(toggleterm): add Esc normal-mode mapping and lazygit float toggle Esc in terminal buffers exits insert mode without the awkward C-\C-n chord. lazygit float on tg avoids context-switching to a separate window. --- lazy-lock.json | 2 ++ lua/custom/plugins/toggle-term.lua | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lazy-lock.json b/lazy-lock.json index 5e76c7dd..2c6cad0d 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -29,8 +29,10 @@ "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, "wezterm.nvim": { "branch": "main", "commit": "032c33b621b96cc7228955b4352b48141c482098" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/custom/plugins/toggle-term.lua b/lua/custom/plugins/toggle-term.lua index 9ac87b18..7f929d1a 100644 --- a/lua/custom/plugins/toggle-term.lua +++ b/lua/custom/plugins/toggle-term.lua @@ -1 +1,18 @@ -return {'akinsho/toggleterm.nvim', version = "*", config = true} +return { + 'akinsho/toggleterm.nvim', + version = '*', + opts = { + open_mapping = [[tt]], + }, + config = function(_, opts) + require('toggleterm').setup(opts) + vim.keymap.set('t', '', [[]], { desc = 'Exit terminal mode' }) + + local lazygit = require('toggleterm.terminal').Terminal:new({ + cmd = 'lazygit', + direction = 'float', + hidden = true, + }) + vim.keymap.set('n', 'tg', function() lazygit:toggle() end, { desc = 'Toggle lazygit' }) + end, +}