mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-23 21:09:48 +01:00
Merge pull request #63 from horriblename/feat-lazygit
feat: lazygit integration
This commit is contained in:
commit
c1d3f37a3c
4 changed files with 79 additions and 26 deletions
|
@ -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`.
|
||||
|
|
|
@ -167,7 +167,10 @@ inputs: let
|
|||
};
|
||||
|
||||
vim.terminal = {
|
||||
toggleterm.enable = true;
|
||||
toggleterm = {
|
||||
enable = true;
|
||||
lazygit.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
vim.ui = {
|
||||
|
|
|
@ -6,31 +6,62 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
toggleKey = "<c-t>";
|
||||
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 = [[<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
|
||||
},
|
||||
})
|
||||
'';
|
||||
};
|
||||
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', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
|
||||
'';
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue