mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 19:11:15 +00: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]]
|
[[sec-release-0.4-changelog]]
|
||||||
=== Changelog
|
=== Changelog
|
||||||
|
|
||||||
|
|
||||||
|
ttps://github.com/horriblename[horriblename]:
|
||||||
|
|
||||||
* Added `clangd` as alternative lsp for C/++.
|
* Added `clangd` as alternative lsp for C/++.
|
||||||
|
|
||||||
|
* Added `toggleterm` integration for `lazygit`.
|
||||||
|
|
|
@ -167,7 +167,10 @@ inputs: let
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.terminal = {
|
vim.terminal = {
|
||||||
toggleterm.enable = true;
|
toggleterm = {
|
||||||
|
enable = true;
|
||||||
|
lazygit.enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.ui = {
|
vim.ui = {
|
||||||
|
|
|
@ -6,31 +6,62 @@
|
||||||
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 = mkMerge [
|
||||||
vim.startPlugins = [
|
(
|
||||||
"toggleterm-nvim"
|
mkIf cfg.enable {
|
||||||
];
|
vim.startPlugins = [
|
||||||
|
"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)
|
||||||
if term.direction == "horizontal" then
|
if term.direction == "horizontal" then
|
||||||
return 15
|
return 15
|
||||||
elseif term.direction == "vertical" then
|
elseif term.direction == "vertical" then
|
||||||
return vim.o.columns * 0.4
|
return vim.o.columns * 0.4
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
winbar = {
|
winbar = {
|
||||||
enabled = '${toString cfg.enable_winbar}',
|
enabled = '${toString cfg.enable_winbar}',
|
||||||
name_formatter = function(term) -- term: Terminal
|
name_formatter = function(term) -- term: Terminal
|
||||||
return term.name
|
return term.name
|
||||||
end
|
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,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -17,5 +18,18 @@ 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";
|
||||||
|
};
|
||||||
|
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