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", "telescope": "telescope",
"tidalcycles": "tidalcycles", "tidalcycles": "tidalcycles",
"todo-comments": "todo-comments", "todo-comments": "todo-comments",
"toggleterm-nvim": "toggleterm-nvim",
"tokyonight": "tokyonight", "tokyonight": "tokyonight",
"trouble": "trouble", "trouble": "trouble",
"venn-nvim": "venn-nvim", "venn-nvim": "venn-nvim",
@ -1162,6 +1163,22 @@
"type": "github" "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": { "tokyonight": {
"flake": false, "flake": false,
"locked": { "locked": {

View file

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

View file

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

View file

@ -27,6 +27,7 @@
./utility ./utility
./presence ./presence
./notes ./notes
./terminal
]; ];
pkgsModule = {config, ...}: { 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
},
})
'';
};
}