mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 10:15:59 +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
|
}: let
|
||||||
inherit (builtins) toJSON;
|
inherit (builtins) toJSON;
|
||||||
inherit (lib.lists) optionals;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.nvim.binds) mkBinding;
|
inherit (lib.nvim.binds) mkLznBinding;
|
||||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
|
||||||
|
|
||||||
cfg = config.vim.terminal.toggleterm;
|
cfg = config.vim.terminal.toggleterm;
|
||||||
|
lazygitMapDesc = "Open lazygit [toggleterm]";
|
||||||
in {
|
in {
|
||||||
config = mkMerge [
|
config = mkIf cfg.enable {
|
||||||
(
|
|
||||||
mkIf cfg.enable {
|
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = [
|
lazy.plugins = [
|
||||||
"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)
|
|
||||||
{
|
{
|
||||||
vim.startPlugins = optionals (cfg.lazygit.package != null) [
|
package = "toggleterm-nvim";
|
||||||
cfg.lazygit.package
|
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 terminal = require 'toggleterm.terminal'
|
||||||
local lazygit = terminal.Terminal:new({
|
local lazygit = terminal.Terminal:new({
|
||||||
cmd = '${
|
cmd = '${
|
||||||
|
@ -50,9 +43,10 @@ in {
|
||||||
end
|
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