From 202eaaf3221234ef3c38191d188fbdf9dd1e61a7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 Feb 2023 02:44:38 +0300 Subject: [PATCH] feat: toggleterm --- flake.lock | 17 +++++++++++ flake.nix | 19 ++++++++++++ modules/lib/types-plugin.nix | 1 + modules/modules.nix | 1 + modules/terminal/default.nix | 5 ++++ modules/terminal/toggleterm.nix | 51 +++++++++++++++++++++++++++++++++ 6 files changed, 94 insertions(+) create mode 100644 modules/terminal/default.nix create mode 100644 modules/terminal/toggleterm.nix diff --git a/flake.lock b/flake.lock index d32c17c..f41a006 100644 --- a/flake.lock +++ b/flake.lock @@ -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": { diff --git a/flake.nix b/flake.nix index 4b8c299..1d29d3f 100644 --- a/flake.nix +++ b/flake.nix @@ -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) diff --git a/modules/lib/types-plugin.nix b/modules/lib/types-plugin.nix index 372b831..30d08c9 100644 --- a/modules/lib/types-plugin.nix +++ b/modules/lib/types-plugin.nix @@ -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)); diff --git a/modules/modules.nix b/modules/modules.nix index be6509f..d4203ca 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -27,6 +27,7 @@ ./utility ./presence ./notes + ./terminal ]; pkgsModule = {config, ...}: { diff --git a/modules/terminal/default.nix b/modules/terminal/default.nix new file mode 100644 index 0000000..228f3ff --- /dev/null +++ b/modules/terminal/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./toggleterm.nix + ]; +} diff --git a/modules/terminal/toggleterm.nix b/modules/terminal/toggleterm.nix new file mode 100644 index 0000000..7c7f5b5 --- /dev/null +++ b/modules/terminal/toggleterm.nix @@ -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 = [[]], + 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 + }, + }) + ''; + }; +}