diff --git a/config/keymaps.nix b/config/keymaps.nix index 70d2b48..1cef5f8 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -168,6 +168,176 @@ desc = "Open Neogit"; }; } + { + mode = "n"; + key = "]c"; + action = { + __raw = '' + function() + if vim.wo.diff then + vim.cmd.normal({']c', bang = true}) + else + require('gitsigns').nav_hunk('next') + end + end + ''; + }; + options = { + silent = true; + noremap = true; + desc = "Go to next hunk"; + }; + } + { + mode = "n"; + key = "[c"; + action = { + __raw = '' + function() + if vim.wo.diff then + vim.cmd.normal({'[c', bang = true}) + else + require('gitsigns').nav_hunk('prev') + end + end + ''; + }; + options = { + silent = true; + noremap = true; + desc = "Go to previous hunk"; + }; + } + { + mode = "n"; + key = "gs"; + action = ":lua require('gitsigns').stage_hunk()"; + options = { + silent = true; + noremap = true; + desc = "Stage hunk"; + }; + } + { + mode = "n"; + key = "gr"; + action = ":lua require('gitsigns').reset_hunk()"; + options = { + silent = true; + noremap = true; + desc = "Reset hunk"; + }; + } + { + mode = "v"; + key = "gs"; + action = ":lua require('gitsigns').stage_hunk {vim.fn.line('.'), vim.fn.line('v')}"; + options = { + silent = true; + noremap = true; + desc = "Stage hunk"; + }; + } + { + mode = "v"; + key = "gr"; + action = ":lua require('gitsigns').reset_hunk {vim.fn.line('.'), vim.fn.line('v')}"; + options = { + silent = true; + noremap = true; + desc = "Reset hunk"; + }; + } + { + mode = "n"; + key = "gS"; + action = ":lua require('gitsigns').stage_buffer()"; + options = { + silent = true; + noremap = true; + desc = "Stage buffer"; + }; + } + { + mode = "n"; + key = "gu"; + action = ":lua require('gitsigns').undo_stage_hunk()"; + options = { + silent = true; + noremap = true; + desc = "Undo stage hunk"; + }; + } + { + mode = "n"; + key = "gR"; + action = ":lua require('gitsigns').reset_buffer()"; + options = { + silent = true; + noremap = true; + desc = "Reset buffer"; + }; + } + { + mode = "n"; + key = "gp"; + action = ":lua require('gitsigns').preview_hunk()"; + options = { + silent = true; + noremap = true; + desc = "Preview hunk"; + }; + } + { + mode = "n"; + key = "gb"; + action = ":lua require('gitsigns').blame_line{full=true}"; + options = { + silent = true; + noremap = true; + desc = "View line blame"; + }; + } + { + mode = "n"; + key = "gB"; + action = ":lua require('gitsigns').toggle_current_line_blame()"; + options = { + silent = true; + noremap = true; + desc = "Toggle line blame"; + }; + } + { + mode = "n"; + key = "gd"; + action = ":lua require('gitsigns').diffthis()"; + options = { + silent = true; + noremap = true; + desc = "Git diff"; + }; + } + { + mode = "n"; + key = "gD"; + action = ":lua require('gitsigns').diffthis('~')"; + options = { + silent = true; + noremap = true; + desc = "Git diff"; + }; + } + { + mode = "n"; + key = "gtd"; + action = ":lua require('gitsigns').toggle_deleted()"; + options = { + silent = true; + noremap = true; + desc = "Toggle git deleted"; + }; + } { action = ":split | wincmd j | resize 15 | term"; key = "tt";