mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 08:36:46 +00:00
feat: gitsigns-codeactions
This commit is contained in:
parent
fdca3b1e7e
commit
84ecf8f3fd
2 changed files with 58 additions and 54 deletions
|
@ -1,13 +1,58 @@
|
||||||
{
|
{
|
||||||
|
pkgs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; {
|
with lib;
|
||||||
config = {
|
with builtins; let
|
||||||
vim.git = {
|
cfg = config.vim.git;
|
||||||
enable = mkDefault false;
|
in {
|
||||||
gitsigns.enable = mkDefault false;
|
config = mkIf cfg.enable (mkMerge [
|
||||||
};
|
(mkIf cfg.gitsigns.enable (mkMerge [
|
||||||
};
|
{
|
||||||
|
vim.startPlugins = ["gitsigns-nvim"];
|
||||||
|
|
||||||
|
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere ''
|
||||||
|
require('gitsigns').setup {
|
||||||
|
keymaps = {
|
||||||
|
noremap = true,
|
||||||
|
|
||||||
|
['n <leader>gn'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns next_hunk<CR>'"},
|
||||||
|
['n <leader>gp'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns prev_hunk<CR>'"},
|
||||||
|
|
||||||
|
['n <leader>gs'] = '<cmd>Gitsigns stage_hunk<CR>',
|
||||||
|
['v <leader>gs'] = ':Gitsigns stage_hunk<CR>',
|
||||||
|
['n <leader>gu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
|
||||||
|
['n <leader>gr'] = '<cmd>Gitsigns reset_hunk<CR>',
|
||||||
|
['v <leader>gr'] = ':Gitsigns reset_hunk<CR>',
|
||||||
|
['n <leader>gR'] = '<cmd>Gitsigns reset_buffer<CR>',
|
||||||
|
['n <leader>gp'] = '<cmd>Gitsigns preview_hunk<CR>',
|
||||||
|
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
|
||||||
|
['n <leader>gS'] = '<cmd>Gitsigns stage_buffer<CR>',
|
||||||
|
['n <leader>gU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
|
||||||
|
['n <leader>gts'] = ':Gitsigns toggle_signs<CR>',
|
||||||
|
['n <leader>gtn'] = ':Gitsigns toggle_numhl<CR>',
|
||||||
|
['n <leader>gtl'] = ':Gitsigns toggle_linehl<CR>',
|
||||||
|
['n <leader>gtw'] = ':Gitsigns toggle_word_diff<CR>',
|
||||||
|
|
||||||
|
-- Text objects
|
||||||
|
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
||||||
|
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
(mkIf cfg.gitsigns.codeActions {
|
||||||
|
vim.lsp.null-ls.enable = true;
|
||||||
|
vim.lsp.null-ls.sources.gitsigns-ca = ''
|
||||||
|
table.insert(
|
||||||
|
ls_sources,
|
||||||
|
null_ls.builtins.code_actions.gitsigns
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
]))
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
pkgs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -8,54 +9,12 @@ with builtins; let
|
||||||
cfg = config.vim.git;
|
cfg = config.vim.git;
|
||||||
in {
|
in {
|
||||||
options.vim.git = {
|
options.vim.git = {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "Git support";
|
||||||
type = types.bool;
|
|
||||||
description = "Enable git plugins";
|
|
||||||
};
|
|
||||||
|
|
||||||
gitsigns.enable = mkOption {
|
gitsigns = {
|
||||||
type = types.bool;
|
enable = mkEnableOption "gitsigns";
|
||||||
description = "Enable git options";
|
|
||||||
|
codeActions = mkEnableOption "gitsigns codeactions through null-ls";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
|
||||||
mkIf cfg.enable
|
|
||||||
{
|
|
||||||
vim.startPlugins =
|
|
||||||
if (cfg.gitsigns.enable)
|
|
||||||
then ["gitsigns-nvim"]
|
|
||||||
else [];
|
|
||||||
|
|
||||||
vim.luaConfigRC.gitsigns = mkIf (cfg.gitsigns.enable) (nvim.dag.entryAnywhere ''
|
|
||||||
-- GitSigns setup
|
|
||||||
require('gitsigns').setup {
|
|
||||||
keymaps = {
|
|
||||||
noremap = true,
|
|
||||||
|
|
||||||
['n <leader>gn'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns next_hunk<CR>'"},
|
|
||||||
['n <leader>gp'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns prev_hunk<CR>'"},
|
|
||||||
|
|
||||||
['n <leader>gs'] = '<cmd>Gitsigns stage_hunk<CR>',
|
|
||||||
['v <leader>gs'] = ':Gitsigns stage_hunk<CR>',
|
|
||||||
['n <leader>gu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
|
|
||||||
['n <leader>gr'] = '<cmd>Gitsigns reset_hunk<CR>',
|
|
||||||
['v <leader>gr'] = ':Gitsigns reset_hunk<CR>',
|
|
||||||
['n <leader>gR'] = '<cmd>Gitsigns reset_buffer<CR>',
|
|
||||||
['n <leader>gp'] = '<cmd>Gitsigns preview_hunk<CR>',
|
|
||||||
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
|
|
||||||
['n <leader>gS'] = '<cmd>Gitsigns stage_buffer<CR>',
|
|
||||||
['n <leader>gU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
|
|
||||||
['n <leader>gts'] = ':Gitsigns toggle_signs<CR>',
|
|
||||||
['n <leader>gtn'] = ':Gitsigns toggle_numhl<CR>',
|
|
||||||
['n <leader>gtl'] = ':Gitsigns toggle_linehl<CR>',
|
|
||||||
['n <leader>gtw'] = ':Gitsigns toggle_word_diff<CR>',
|
|
||||||
|
|
||||||
-- Text objects
|
|
||||||
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
|
||||||
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue