From 5e15695ea778fb99d72c4e88b075e4cf6d6b3cc6 Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Thu, 25 Jan 2024 01:22:53 -0600 Subject: [PATCH 1/6] install git fugitive and create initial git shortcuts --- lazy-lock.json | 1 - lua/plugins/fugitive.lua | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 lua/plugins/fugitive.lua diff --git a/lazy-lock.json b/lazy-lock.json index 0831d179..5f7ad537 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -19,7 +19,6 @@ "nvim-treesitter": { "branch": "master", "commit": "ab818bf5a2ee21515ade9afcf428e98056b6197b" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" }, "oil.nvim": { "branch": "master", "commit": "24027ed8d7f3ee5c38cfd713915e2e16d89e79b3" }, - "onedark.nvim": { "branch": "master", "commit": "c5476a091b0f1b4e853db91c91ff941f848a1cdd" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua new file mode 100644 index 00000000..f04de7c8 --- /dev/null +++ b/lua/plugins/fugitive.lua @@ -0,0 +1,7 @@ +return { 'tpope/vim-fugitive', + config = function() + vim.keymap.set('n', 'gs', 'Git', { desc = '[G]it [S]tatus' }); + vim.keymap.set('n', 'ga', 'Git add -A', { desc = 'Stage [A]ll [G]it files' }); + vim.keymap.set('n', 'gc', 'Git commit', { desc = '[C]ommit staged [G]it files' }); + end +}; From 95532ea93b99c38f99b5a4abd4f09885f7f29e94 Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Thu, 25 Jan 2024 01:29:15 -0600 Subject: [PATCH 2/6] add shortcut to git log graph oneline --- lua/plugins/fugitive.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index f04de7c8..1a0aa0d5 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -3,5 +3,6 @@ return { 'tpope/vim-fugitive', vim.keymap.set('n', 'gs', 'Git', { desc = '[G]it [S]tatus' }); vim.keymap.set('n', 'ga', 'Git add -A', { desc = 'Stage [A]ll [G]it files' }); vim.keymap.set('n', 'gc', 'Git commit', { desc = '[C]ommit staged [G]it files' }); + vim.keymap.set('n', 'gg', 'Git log --graph --oneline', { desc = '[G]it log [G]raph' }); end }; From 0f98cf51a45d659bb674874d251ad7b43de20006 Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Thu, 25 Jan 2024 01:39:23 -0600 Subject: [PATCH 3/6] stage git hunk command as git subcommands --- lua/plugins/gitsigns.lua | 22 +++++++++++----------- lua/plugins/whichkey.lua | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 0b1c7378..1d4223ee 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -41,24 +41,24 @@ return { -- Actions -- visual mode - map('v', 'hs', function() + map('v', 'ghs', function() gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } end, { desc = 'stage git hunk' }) - map('v', 'hr', function() + map('v', 'ghr', function() gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } end, { desc = 'reset git hunk' }) -- normal mode - map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) - map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) - map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) - map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) - map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) - map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) - map('n', 'hb', function() + map('n', 'ghs', gs.stage_hunk, { desc = 'git stage hunk' }) + map('n', 'ghr', gs.reset_hunk, { desc = 'git reset hunk' }) + map('n', 'ghS', gs.stage_buffer, { desc = 'git Stage buffer' }) + map('n', 'ghu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) + map('n', 'ghR', gs.reset_buffer, { desc = 'git Reset buffer' }) + map('n', 'ghp', gs.preview_hunk, { desc = 'preview git hunk' }) + map('n', 'ghb', function() gs.blame_line { full = false } end, { desc = 'git blame line' }) - map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) - map('n', 'hD', function() + map('n', 'ghd', gs.diffthis, { desc = 'git diff against index' }) + map('n', 'ghD', function() gs.diffthis '~' end, { desc = 'git diff against last commit' }) diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua index 7dc820a9..c5dbc061 100644 --- a/lua/plugins/whichkey.lua +++ b/lua/plugins/whichkey.lua @@ -5,7 +5,7 @@ return { 'folke/which-key.nvim', opts = {}, ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + ['gh'] = { name = '[G]it [H]unk', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, From 5eb3d923c14913d2cd586ada5359878811049a0f Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Thu, 25 Jan 2024 01:51:39 -0600 Subject: [PATCH 4/6] fix labeling and remove unused git hunk shortcuts --- lua/plugins/gitsigns.lua | 27 +++++++++++---------------- lua/plugins/whichkey.lua | 1 - 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 1d4223ee..9865461d 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -43,31 +43,26 @@ return { -- visual mode map('v', 'ghs', function() gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) + end, { desc = '[S]tage [G]it [H]unk' }) map('v', 'ghr', function() gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) + end, { desc = '[R]eset [G]it [H]unk' }) -- normal mode - map('n', 'ghs', gs.stage_hunk, { desc = 'git stage hunk' }) - map('n', 'ghr', gs.reset_hunk, { desc = 'git reset hunk' }) - map('n', 'ghS', gs.stage_buffer, { desc = 'git Stage buffer' }) - map('n', 'ghu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) - map('n', 'ghR', gs.reset_buffer, { desc = 'git Reset buffer' }) - map('n', 'ghp', gs.preview_hunk, { desc = 'preview git hunk' }) + map('n', 'ghs', gs.stage_hunk, { desc = '[G]it [S]tage [H]unk' }) + map('n', 'ghr', gs.reset_hunk, { desc = '[G]it [R]eset [H]unk' }) + map('n', 'ghS', gs.stage_buffer, { desc = '[G]it [S]tage buffer' }) + map('n', 'ghu', gs.undo_stage_hunk, { desc = '[U]ndo stage [H]unk' }) + map('n', 'ghR', gs.reset_buffer, { desc = '[G]it [R]eset buffer' }) + map('n', 'ghp', gs.preview_hunk, { desc = '[P]review [G]it [H]unk' }) map('n', 'ghb', function() gs.blame_line { full = false } - end, { desc = 'git blame line' }) - map('n', 'ghd', gs.diffthis, { desc = 'git diff against index' }) - map('n', 'ghD', function() - gs.diffthis '~' - end, { desc = 'git diff against last commit' }) + end, { desc = '[G]it blame line' }) -- Toggles - map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) - map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) + map('n', 'ghx', gs.toggle_deleted, { desc = 'toggle [G]it show deleted' }) -- Text object - map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select [G]it [H]unk' }) end } } diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua index c5dbc061..2e7edbc9 100644 --- a/lua/plugins/whichkey.lua +++ b/lua/plugins/whichkey.lua @@ -8,7 +8,6 @@ return { 'folke/which-key.nvim', opts = {}, ['gh'] = { name = '[G]it [H]unk', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, } -- register which-key VISUAL mode From a5e4878030f13537597cd9921b4190368d08c130 Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Thu, 25 Jan 2024 01:57:33 -0600 Subject: [PATCH 5/6] add git blame shortcut --- lua/plugins/fugitive.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index 1a0aa0d5..db236f84 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -4,5 +4,6 @@ return { 'tpope/vim-fugitive', vim.keymap.set('n', 'ga', 'Git add -A', { desc = 'Stage [A]ll [G]it files' }); vim.keymap.set('n', 'gc', 'Git commit', { desc = '[C]ommit staged [G]it files' }); vim.keymap.set('n', 'gg', 'Git log --graph --oneline', { desc = '[G]it log [G]raph' }); + vim.keymap.set('n', 'gb', 'Git blame', { desc = '[G]it [B]lame' }); end }; From f047e7db9ca26b6e092c0f6b30f73ba4f3a10a6a Mon Sep 17 00:00:00 2001 From: Nick Burt Date: Thu, 25 Jan 2024 13:00:36 -0600 Subject: [PATCH 6/6] show branch names in git graph view --- lua/plugins/fugitive.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index db236f84..af264934 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -3,7 +3,7 @@ return { 'tpope/vim-fugitive', vim.keymap.set('n', 'gs', 'Git', { desc = '[G]it [S]tatus' }); vim.keymap.set('n', 'ga', 'Git add -A', { desc = 'Stage [A]ll [G]it files' }); vim.keymap.set('n', 'gc', 'Git commit', { desc = '[C]ommit staged [G]it files' }); - vim.keymap.set('n', 'gg', 'Git log --graph --oneline', { desc = '[G]it log [G]raph' }); + vim.keymap.set('n', 'gg', 'Git log --graph --oneline --decorate=short', { desc = '[G]it log [G]raph' }); vim.keymap.set('n', 'gb', 'Git blame', { desc = '[G]it [B]lame' }); end };