From 8c6b1a59acec18c2e4ec34fa586421b9ab7bd587 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 8 Mar 2023 09:13:59 +0200 Subject: Fixed not reloading git directories on different project files and toggling between standard toggleterm/lazygit terminals --- lua/plugins/toggleterm.lua | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index 0be6548..a9bd450 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -77,12 +77,11 @@ end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') ---vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") - local Terminal = require("toggleterm.terminal").Terminal local lazygit = Terminal:new({ cmd = "lazygit", count = 5, + id = 1000, dir = "git_dir", direction = "float", on_open = float_handler, @@ -107,18 +106,18 @@ local lazygit = Terminal:new({ -- vim.cmd("startinsert!") --end }) -local cur_cwd = vim.fn.getcwd() function Lazygit_toggle() -- cwd is the root of project. if cwd is changed, change the git. local cwd = vim.fn.getcwd() - if cwd ~= cur_cwd then - cur_cwd = cwd + if cwd ~= Cur_cwd then + Cur_cwd = cwd lazygit:close() lazygit = Terminal:new({ cmd = "lazygit", dir = "git_dir", direction = "float", + hidden = true, on_open = float_handler, float_opts = { border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, @@ -129,20 +128,6 @@ function Lazygit_toggle() end lazygit:toggle() end ---function Lazygit_toggle() --- lazygit:toggle() ---end - ---vim.keymap.set({"n", "t"}, "gg", function() --- -- custom function to find the git directory for the current buffer --- --local git_root = project_utils.git_root() or vim.fn.getcwd() --- local git_root = vim.fn.getcwd() --- --- lazygit.cmd = 'gitui -d ' .. git_root --- --"lua lazygit_toggle()" --- lazygit:toggle() ---end, { desc = 'Toggle gitui' }) - local node = Terminal:new({ cmd = "node", hidden = true }) -- cgit v1.2.3