diff --git a/docs/release-notes/rl-0.4.adoc b/docs/release-notes/rl-0.4.adoc index 6f35b5d2..ddf5f75b 100644 --- a/docs/release-notes/rl-0.4.adoc +++ b/docs/release-notes/rl-0.4.adoc @@ -7,4 +7,9 @@ Release notes for release 0.4 [[sec-release-0.4-changelog]] === Changelog + +ttps://github.com/horriblename[horriblename]: + * Added `clangd` as alternative lsp for C/++. + +* Added `toggleterm` integration for `lazygit`. diff --git a/extra.nix b/extra.nix index fa1f4d96..767d5dd6 100644 --- a/extra.nix +++ b/extra.nix @@ -167,7 +167,10 @@ inputs: let }; vim.terminal = { - toggleterm.enable = true; + toggleterm = { + enable = true; + lazygit.enable = true; + }; }; vim.ui = { diff --git a/modules/terminal/toggleterm/config.nix b/modules/terminal/toggleterm/config.nix index 9e98bb12..868dec4e 100644 --- a/modules/terminal/toggleterm/config.nix +++ b/modules/terminal/toggleterm/config.nix @@ -6,31 +6,62 @@ with lib; with builtins; let cfg = config.vim.terminal.toggleterm; + toggleKey = ""; in { - config = mkIf cfg.enable { - vim.startPlugins = [ - "toggleterm-nvim" - ]; + config = mkMerge [ + ( + 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 - }, - }) - ''; - }; + vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere '' + require("toggleterm").setup({ + open_mapping = [[${toggleKey}]], + 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 + }, + }) + ''; + } + ) + ( + mkIf (cfg.enable && cfg.lazygit.enable) + { + vim.startPlugins = lib.optionals (cfg.lazygit.package != null) [ + cfg.lazygit.package + ]; + vim.luaConfigRC.toggleterm-lazygit = nvim.dag.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!") + vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr}) + end + }) + + vim.keymap.set( 'n', [[gg]], function() lazygit:toggle() end, {silent = true, noremap = true}) + ''; + } + ) + ]; } diff --git a/modules/terminal/toggleterm/toggleterm.nix b/modules/terminal/toggleterm/toggleterm.nix index e2ed9401..09b03f25 100644 --- a/modules/terminal/toggleterm/toggleterm.nix +++ b/modules/terminal/toggleterm/toggleterm.nix @@ -1,4 +1,5 @@ { + pkgs, config, lib, ... @@ -17,5 +18,18 @@ with builtins; { default = false; description = "Enable winbar"; }; + lazygit = { + enable = mkEnableOption "Enable LazyGit integration"; + direction = mkOption { + type = types.enum ["horizontal" "vertical" "tab" "float"]; + default = "float"; + description = "Direction of the lazygit window"; + }; + package = mkOption { + type = with types; 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"; + }; + }; }; }