mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00: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 builtins; let
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
toggleKey = "<c-t>";
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"toggleterm-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere (''
|
||||
require("toggleterm").setup({
|
||||
open_mapping = [[<c-t>]],
|
||||
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)
|
||||
|
@ -31,6 +32,21 @@ in {
|
|||
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;
|
||||
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