use separate dag for toggleterm

This commit is contained in:
Ching Pei Yang 2023-04-27 12:41:59 +02:00
parent 24b631f343
commit f8ff3cd9fa

View file

@ -8,12 +8,13 @@ with builtins; let
cfg = config.vim.terminal.toggleterm; cfg = config.vim.terminal.toggleterm;
toggleKey = "<c-t>"; toggleKey = "<c-t>";
in { in {
config = mkIf cfg.enable { config = mkMerge [
(mkIf cfg.enable {
vim.startPlugins = [ vim.startPlugins = [
"toggleterm-nvim" "toggleterm-nvim"
]; ];
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ('' vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
require("toggleterm").setup({ require("toggleterm").setup({
open_mapping = [[${toggleKey}]], open_mapping = [[${toggleKey}]],
direction = '${toString cfg.direction}', direction = '${toString cfg.direction}',
@ -32,9 +33,13 @@ in {
end end
}, },
}) })
'' '';
+ optionalString cfg.lazygit.enable '' }
)
(
mkIf (cfg.enable && cfg.lazygit.enable)
{
vim.luaConfigRC.toggleterm-lazygit = mkIf cfg.lazygit.enable nvim.dag.entryAfter ["toggleterm"] ''
local terminal = require 'toggleterm.terminal' local terminal = require 'toggleterm.terminal'
local lazygit = terminal.Terminal:new({ local lazygit = terminal.Terminal:new({
cmd = "lazygit", cmd = "lazygit",
@ -47,6 +52,8 @@ in {
}) })
vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true}) vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
''); '';
}; }
)
];
} }