mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 15:39:49 +01:00
feat: lazygit integration
This commit is contained in:
parent
9e224d710c
commit
24b631f343
2 changed files with 43 additions and 19 deletions
|
@ -6,15 +6,16 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.terminal.toggleterm;
|
cfg = config.vim.terminal.toggleterm;
|
||||||
|
toggleKey = "<c-t>";
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"toggleterm-nvim"
|
"toggleterm-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere (''
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
open_mapping = [[<c-t>]],
|
open_mapping = [[${toggleKey}]],
|
||||||
direction = '${toString cfg.direction}',
|
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
|
-- 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)
|
size = function(term)
|
||||||
|
@ -31,6 +32,21 @@ in {
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
'';
|
''
|
||||||
|
+ optionalString cfg.lazygit.enable ''
|
||||||
|
|
||||||
|
local terminal = require 'toggleterm.terminal'
|
||||||
|
local lazygit = terminal.Terminal:new({
|
||||||
|
cmd = "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})
|
||||||
|
'');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,13 @@ with builtins; {
|
||||||
default = false;
|
default = false;
|
||||||
description = "Enable winbar";
|
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue