mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-22 20:01:17 +00:00
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
62 lines
1.8 KiB
Nix
62 lines
1.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit (lib.strings) optionalString;
|
|
inherit (lib.lists) optional;
|
|
inherit (lib.modules) mkIf;
|
|
inherit (lib.meta) getExe;
|
|
inherit (lib.nvim.binds) mkKeymap;
|
|
inherit (lib.nvim.lua) toLuaObject;
|
|
|
|
cfg = config.vim.terminal.toggleterm;
|
|
lazygitMapDesc = "Open lazygit [toggleterm]";
|
|
in {
|
|
config = mkIf cfg.enable {
|
|
vim = {
|
|
lazy.plugins.toggleterm-nvim = {
|
|
package = "toggleterm-nvim";
|
|
cmd = [
|
|
"ToggleTerm"
|
|
"ToggleTermSendCurrentLine"
|
|
"ToggleTermSendVisualLines"
|
|
"ToggleTermSendVisualSelection"
|
|
"ToggleTermSetName"
|
|
"ToggleTermToggleAll"
|
|
];
|
|
keys =
|
|
[
|
|
(mkKeymap ["n" "t"] cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" {
|
|
desc = "Toggle terminal";
|
|
})
|
|
]
|
|
++ optional cfg.lazygit.enable {
|
|
key = cfg.lazygit.mappings.open;
|
|
mode = "n";
|
|
desc = lazygitMapDesc;
|
|
};
|
|
|
|
setupModule = "toggleterm";
|
|
inherit (cfg) setupOpts;
|
|
after = optionalString cfg.lazygit.enable ''
|
|
local terminal = require 'toggleterm.terminal'
|
|
local lazygit = terminal.Terminal:new({
|
|
cmd = '${
|
|
if (cfg.lazygit.package != null)
|
|
then getExe cfg.lazygit.package
|
|
else "lazygit"
|
|
}',
|
|
direction = '${cfg.lazygit.direction}',
|
|
hidden = true,
|
|
on_open = function(term)
|
|
vim.cmd("startinsert!")
|
|
end
|
|
})
|
|
|
|
vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|