feat: toggleterm

This commit is contained in:
NotAShelf 2023-02-06 02:44:38 +03:00
parent d867dae743
commit 202eaaf322
No known key found for this signature in database
GPG Key ID: 5B5C8895F28445F1
6 changed files with 94 additions and 0 deletions

View File

@ -975,6 +975,7 @@
"telescope": "telescope",
"tidalcycles": "tidalcycles",
"todo-comments": "todo-comments",
"toggleterm-nvim": "toggleterm-nvim",
"tokyonight": "tokyonight",
"trouble": "trouble",
"venn-nvim": "venn-nvim",
@ -1162,6 +1163,22 @@
"type": "github"
}
},
"toggleterm-nvim": {
"flake": false,
"locked": {
"lastModified": 1675358836,
"narHash": "sha256-9O7p/7tRStg51OFhMc88M5ewYquiYC9x9CV4s5veVP8=",
"owner": "akinsho",
"repo": "toggleterm.nvim",
"rev": "19aad0f41f47affbba1274f05e3c067e6d718e1e",
"type": "github"
},
"original": {
"owner": "akinsho",
"repo": "toggleterm.nvim",
"type": "github"
}
},
"tokyonight": {
"flake": false,
"locked": {

View File

@ -102,36 +102,45 @@
};
};
vim.tabline.nvimBufferline.enable = true;
vim.treesitter = {
enable = true;
context.enable = true;
};
vim.binds = {
whichKey.enable = true;
cheatsheet.enable = true;
};
vim.telescope = {
enable = true;
};
vim.markdown = {
enable = true;
glow.enable = true;
};
vim.git = {
enable = true;
gitsigns.enable = true;
};
vim.minimap = {
minimap-vim.enable = false;
codewindow.enable = true; # lighter, faster, and uses lua for configuration
};
vim.dashboard = {
dashboard-nvim.enable = false;
alpha.enable = true;
};
vim.notify = {
nvim-notify.enable = true;
};
vim.utility = {
colorizer.enable = true;
icon-picker.enable = true;
@ -142,6 +151,10 @@
obsidian.enable = false; # FIXME neovim fails to build if obsidian is enabled
orgmode.enable = true;
};
vim.terminal = {
toggleterm.enable = true;
};
};
};
@ -528,6 +541,12 @@
flake = false;
};
# Terminal
toggleterm-nvim = {
url = "github:akinsho/toggleterm.nvim";
flake = false;
};
# Dependencies
plenary-nvim = {
# (required by crates-nvim)

View File

@ -59,6 +59,7 @@ with lib; let
"obsidian-nvim"
"vim-markdown"
"tabular"
"toggleterm-nvim"
];
# You can either use the name of the plugin or a package.
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));

View File

@ -27,6 +27,7 @@
./utility
./presence
./notes
./terminal
];
pkgsModule = {config, ...}: {

View File

@ -0,0 +1,5 @@
_: {
imports = [
./toggleterm.nix
];
}

View File

@ -0,0 +1,51 @@
{
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 = "float";
description = "Direction of the terminal";
};
enable_winbar = mkOption {
type = types.bool;
default = false;
description = "Enable winbar";
};
};
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
},
})
'';
};
}