2023-02-01 19:11:37 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 00:50:27 +00:00
|
|
|
}: let
|
2023-11-14 07:18:32 +00:00
|
|
|
inherit (builtins) toJSON;
|
|
|
|
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim;
|
|
|
|
|
2023-04-17 21:55:12 +00:00
|
|
|
cfg = config.vim.git;
|
2023-04-22 16:47:19 +00:00
|
|
|
|
|
|
|
self = import ./git.nix {inherit lib;};
|
|
|
|
gsMappingDefinitions = self.options.vim.git.gitsigns.mappings;
|
|
|
|
|
|
|
|
gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions;
|
2023-04-17 21:55:12 +00:00
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
(mkIf cfg.gitsigns.enable (mkMerge [
|
|
|
|
{
|
|
|
|
vim.startPlugins = ["gitsigns-nvim"];
|
|
|
|
|
2023-04-22 16:47:19 +00:00
|
|
|
vim.maps.normal = mkMerge [
|
|
|
|
(mkSetExprBinding gsMappings.nextHunk ''
|
|
|
|
function()
|
2023-11-14 07:18:32 +00:00
|
|
|
if vim.wo.diff then return ${toJSON gsMappings.nextHunk.value} end
|
2023-04-22 16:47:19 +00:00
|
|
|
|
|
|
|
vim.schedule(function() package.loaded.gitsigns.next_hunk() end)
|
|
|
|
|
|
|
|
return '<Ignore>'
|
|
|
|
end
|
|
|
|
'')
|
|
|
|
(mkSetExprBinding gsMappings.previousHunk ''
|
|
|
|
function()
|
2023-11-14 07:18:32 +00:00
|
|
|
if vim.wo.diff then return ${toJSON gsMappings.previousHunk.value} end
|
2023-04-22 16:47:19 +00:00
|
|
|
|
|
|
|
vim.schedule(function() package.loaded.gitsigns.prev_hunk() end)
|
|
|
|
|
|
|
|
return '<Ignore>'
|
|
|
|
end
|
|
|
|
'')
|
|
|
|
|
|
|
|
(mkSetLuaBinding gsMappings.stageHunk "package.loaded.gitsigns.stage_hunk")
|
|
|
|
(mkSetLuaBinding gsMappings.resetHunk "package.loaded.gitsigns.reset_hunk")
|
|
|
|
(mkSetLuaBinding gsMappings.undoStageHunk "package.loaded.gitsigns.undo_stage_hunk")
|
|
|
|
|
|
|
|
(mkSetLuaBinding gsMappings.stageBuffer "package.loaded.gitsigns.stage_buffer")
|
|
|
|
(mkSetLuaBinding gsMappings.resetBuffer "package.loaded.gitsigns.reset_buffer")
|
|
|
|
|
|
|
|
(mkSetLuaBinding gsMappings.previewHunk "package.loaded.gitsigns.preview_hunk")
|
|
|
|
|
|
|
|
(mkSetLuaBinding gsMappings.blameLine "function() package.loaded.gitsigns.blame_line{full=true} end")
|
|
|
|
(mkSetLuaBinding gsMappings.toggleBlame "package.loaded.gitsigns.toggle_current_line_blame")
|
|
|
|
|
|
|
|
(mkSetLuaBinding gsMappings.diffThis "package.loaded.gitsigns.diffthis")
|
|
|
|
(mkSetLuaBinding gsMappings.diffProject "function() package.loaded.gitsigns.diffthis('~') end")
|
|
|
|
|
|
|
|
(mkSetLuaBinding gsMappings.toggleDeleted "package.loaded.gitsigns.toggle_deleted")
|
|
|
|
];
|
|
|
|
|
|
|
|
vim.maps.visual = mkMerge [
|
|
|
|
(mkSetLuaBinding gsMappings.stageHunk "function() package.loaded.gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
|
|
|
(mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
|
|
|
];
|
|
|
|
|
2023-04-17 21:55:12 +00:00
|
|
|
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere ''
|
2023-04-22 16:47:19 +00:00
|
|
|
require('gitsigns').setup{}
|
2023-04-17 21:55:12 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf cfg.gitsigns.codeActions {
|
|
|
|
vim.lsp.null-ls.enable = true;
|
|
|
|
vim.lsp.null-ls.sources.gitsigns-ca = ''
|
|
|
|
table.insert(
|
|
|
|
ls_sources,
|
2024-02-12 06:35:59 +00:00
|
|
|
null_ls.builtins.code_actions.gitsigns
|
2023-04-17 21:55:12 +00:00
|
|
|
)
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
]))
|
|
|
|
]);
|
2023-02-01 19:11:37 +00:00
|
|
|
}
|