{ lib, ... }: {
imports = [
./log
./restore.nix
./status.nix
];
my.nvim.snacks.setupArgs.picker = {
actions = let
fugitive = command: lib.generators.mkLuaInline /*lua*/ ''
function(picker, item)
local dir = vim.fn.FugitiveExtractGitDir(item and item.cwd or picker:cwd())
if dir == "" then return Snacks.notify.warn("Not in a Git repository") end
picker:close()
-- :Git rejects -C; pass the picker's Git dir to its command handler instead.
vim.cmd(vim.fn["fugitive#Command"](-1, -1, 0, 0, "", "${command}", dir))
end
'';
in {
git_commit = fugitive "commit";
git_push = fugitive "push";
git_pull_ff = fugitive "pull --ff-only";
};
};
}