mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
58
modules/plugins/terminal/toggleterm/config.nix
Normal file
58
modules/plugins/terminal/toggleterm/config.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
in {
|
||||
config = mkMerge [
|
||||
(
|
||||
mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"toggleterm-nvim"
|
||||
];
|
||||
|
||||
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||
|
||||
luaConfigRC.toggleterm = entryAnywhere ''
|
||||
require("toggleterm").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
}
|
||||
)
|
||||
(
|
||||
mkIf (cfg.enable && cfg.lazygit.enable)
|
||||
{
|
||||
vim.startPlugins = optionals (cfg.lazygit.package != null) [
|
||||
cfg.lazygit.package
|
||||
];
|
||||
vim.luaConfigRC.toggleterm-lazygit = entryAfter ["toggleterm"] ''
|
||||
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', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
|
||||
'';
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
6
modules/plugins/terminal/toggleterm/default.nix
Normal file
6
modules/plugins/terminal/toggleterm/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./toggleterm.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
87
modules/plugins/terminal/toggleterm/toggleterm.nix
Normal file
87
modules/plugins/terminal/toggleterm/toggleterm.nix
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.types) nullOr str enum bool package either int;
|
||||
inherit (lib) mkRenamedOptionModule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"])
|
||||
(mkRenamedOptionModule ["vim" "terminal" "toggleterm" "enable_winbar"] ["vim" "terminal" "toggleterm" "setupOpts" "enable_winbar"])
|
||||
];
|
||||
|
||||
options.vim.terminal.toggleterm = {
|
||||
enable = mkEnableOption "toggleterm as a replacement to built-in terminal command";
|
||||
mappings = {
|
||||
open = mkOption {
|
||||
type = nullOr str;
|
||||
description = "The keymapping to open toggleterm";
|
||||
default = "<c-t>";
|
||||
};
|
||||
};
|
||||
|
||||
setupOpts = mkPluginSetupOption "ToggleTerm" {
|
||||
direction = mkOption {
|
||||
type = enum ["horizontal" "vertical" "tab" "float"];
|
||||
default = "horizontal";
|
||||
description = "Direction of the terminal";
|
||||
};
|
||||
|
||||
enable_winbar = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Enable winbar";
|
||||
};
|
||||
|
||||
size = mkOption {
|
||||
type = either luaInline int;
|
||||
description = "Number or lua function which is passed to the current terminal";
|
||||
default = mkLuaInline ''
|
||||
function(term)
|
||||
if term.direction == "horizontal" then
|
||||
return 15
|
||||
elseif term.direction == "vertical" then
|
||||
return vim.o.columns * 0.4
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
winbar = {
|
||||
enabled = mkEnableOption "winbar in terminal" // {default = true;};
|
||||
name_formatter = mkOption {
|
||||
type = luaInline;
|
||||
description = "Winbar formatter function.";
|
||||
default = mkLuaInline ''
|
||||
function(term)
|
||||
return term.name
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lazygit = {
|
||||
enable = mkEnableOption "LazyGit integration";
|
||||
direction = mkOption {
|
||||
type = enum ["horizontal" "vertical" "tab" "float"];
|
||||
default = "float";
|
||||
description = "Direction of the lazygit window";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = nullOr package;
|
||||
default = pkgs.lazygit;
|
||||
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
|
||||
};
|
||||
|
||||
mappings = {
|
||||
open = mkMappingOption "Open lazygit [toggleterm]" "<leader>gg";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue