diff --git a/plugins/toggleterm.nix b/plugins/toggleterm.nix index 5199af8..7e4aaaa 100644 --- a/plugins/toggleterm.nix +++ b/plugins/toggleterm.nix @@ -1,7 +1,18 @@ # homepage: https://github.com/akinsho/toggleterm.nvim # nixvim doc: https://nix-community.github.io/nixvim/plugins/toggleterm/index.html _: +let + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/toggleterm.lua#L14-L19 + lazygit_exec = '' + function() + local worktree = require("astrocore").file_worktree() + local flags = worktree and (" --work-tree=%s --git-dir=%s"):format(worktree.toplevel, worktree.gitdir) + or "" + require("astrocore").toggle_term_cmd(table.concat({"lazygit", flags})) + end + ''; +in { opts = { enable = true; @@ -101,5 +112,17 @@ _: action = "TermSelect"; options.desc = "List terminals"; } + { + mode = "n"; + key = "gg"; + action.__raw = lazygit_exec; + options.desc = "ToggleTerm lazygit"; + } + { + mode = "n"; + key = "tl"; + action.__raw = lazygit_exec; + options.desc = "ToggleTerm lazygit"; + } ]; }