mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 08:05:58 +01:00
toggleterm: lazy load
This commit is contained in:
parent
6c92f6cec5
commit
bb2b3ff225
1 changed files with 37 additions and 43 deletions
|
@ -4,38 +4,31 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
lazygitMapDesc = "Open lazygit [toggleterm]";
|
||||
in {
|
||||
config = mkMerge [
|
||||
(
|
||||
mkIf cfg.enable {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"toggleterm-nvim"
|
||||
];
|
||||
|
||||
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||
|
||||
pluginRC.toggleterm = entryAnywhere ''
|
||||
require("toggleterm").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
}
|
||||
)
|
||||
(
|
||||
mkIf (cfg.enable && cfg.lazygit.enable)
|
||||
lazy.plugins = [
|
||||
{
|
||||
vim.startPlugins = optionals (cfg.lazygit.package != null) [
|
||||
cfg.lazygit.package
|
||||
package = "toggleterm-nvim";
|
||||
cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"];
|
||||
keys = [
|
||||
(mkLznBinding ["n"] cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal")
|
||||
{
|
||||
key = cfg.lazygit.mappings.open;
|
||||
desc = lazygitMapDesc;
|
||||
}
|
||||
];
|
||||
vim.pluginRC.toggleterm-lazygit = entryAfter ["toggleterm"] ''
|
||||
|
||||
setupModule = "toggleterm";
|
||||
inherit (cfg) setupOpts;
|
||||
after = optionalString cfg.lazygit.enable ''
|
||||
local terminal = require 'toggleterm.terminal'
|
||||
local lazygit = terminal.Terminal:new({
|
||||
cmd = '${
|
||||
|
@ -50,9 +43,10 @@ in {
|
|||
end
|
||||
})
|
||||
|
||||
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
|
||||
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
|
||||
'';
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue