mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
feat: apply new module format to terminal plugins
This commit is contained in:
parent
848fc5f57c
commit
cbf1490308
4 changed files with 31 additions and 15 deletions
37
modules/terminal/toggleterm/config.nix
Normal file
37
modules/terminal/toggleterm/config.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"toggleterm-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||
require("toggleterm").setup({
|
||||
open_mapping = [[<c-t>]],
|
||||
direction = '${toString cfg.direction}',
|
||||
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
||||
size = function(term)
|
||||
if term.direction == "horizontal" then
|
||||
return 15
|
||||
elseif term.direction == "vertical" then
|
||||
return vim.o.columns * 0.4
|
||||
end
|
||||
end,
|
||||
winbar = {
|
||||
enabled = '${toString cfg.enable_winbar}',
|
||||
name_formatter = function(term) -- term: Terminal
|
||||
return term.name
|
||||
end
|
||||
},
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/terminal/toggleterm/default.nix
Normal file
6
modules/terminal/toggleterm/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./toggleterm.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
24
modules/terminal/toggleterm/toggleterm.nix
Normal file
24
modules/terminal/toggleterm/toggleterm.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
in {
|
||||
options.vim.terminal.toggleterm = {
|
||||
enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command";
|
||||
direction = mkOption {
|
||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||
default = "horizontal";
|
||||
description = "Direction of the terminal";
|
||||
};
|
||||
enable_winbar = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable winbar";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue