From 4fd10f828e862360adadf3f0999806f133ac489d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E9=91=AB?= Date: Fri, 21 Feb 2025 18:19:28 +0800 Subject: [PATCH] optimize: don't create lazygit term until toggle --- lua/plugins/visuals.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/plugins/visuals.lua b/lua/plugins/visuals.lua index 810f241..3193e09 100644 --- a/lua/plugins/visuals.lua +++ b/lua/plugins/visuals.lua @@ -89,13 +89,16 @@ return { 'akinsho/toggleterm.nvim', config = function() local Terminal = require('toggleterm.terminal').Terminal - local lazygit = Terminal:new({ - cmd = "lazygit", - hidden = true, - direction = 'float', - }) + local lazygit = nil function _lazygit_toggle() + if lazygit == nil then + lazygit = Terminal:new({ + cmd = "lazygit", + hidden = true, + direction = 'float', + }) + end lazygit:toggle() end