From 187bebcbf93a82c29f12d946136b8d35ab695c64 Mon Sep 17 00:00:00 2001 From: Luiz Antonio Calliari Filho Date: Sun, 26 Feb 2023 23:03:34 -0300 Subject: Adding [+c and ]+c to move to diffs and leader+ph to show a pop up with the preview diff value. --- init.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/init.lua b/init.lua index aeca6d2..427af75 100644 --- a/init.lua +++ b/init.lua @@ -109,6 +109,19 @@ require('lazy').setup({ topdelete = { text = '‾' }, changedelete = { text = '~' }, }, + on_attach = function(bufnr) + local function map(mode, lhs, rhs, opts) + opts = vim.tbl_extend('force', {noremap = true, silent = true}, opts or {}) + vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) + end + + -- Navigation + map('n', ']c', "&diff ? ']c' : 'Gitsigns next_hunk'", {expr=true}) + map('n', '[c', "&diff ? '[c' : 'Gitsigns prev_hunk'", {expr=true}) + + -- Actions + map('n', 'ph', 'Gitsigns preview_hunk') + end }, }, -- cgit v1.2.3-70-g09d2 From 66dc5b896d47ed58e9821b8b39588ce431bfd83a Mon Sep 17 00:00:00 2001 From: Luiz Antonio Calliari Filho Date: Mon, 6 Mar 2023 23:26:20 -0300 Subject: Feat: Simplifying code --- init.lua | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index 427af75..9ce29c6 100644 --- a/init.lua +++ b/init.lua @@ -110,17 +110,9 @@ require('lazy').setup({ changedelete = { text = '~' }, }, on_attach = function(bufnr) - local function map(mode, lhs, rhs, opts) - opts = vim.tbl_extend('force', {noremap = true, silent = true}, opts or {}) - vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) - end - - -- Navigation - map('n', ']c', "&diff ? ']c' : 'Gitsigns next_hunk'", {expr=true}) - map('n', '[c', "&diff ? '[c' : 'Gitsigns prev_hunk'", {expr=true}) - - -- Actions - map('n', 'ph', 'Gitsigns preview_hunk') + vim.keymap.set('n', '[c', require('gitsigns').prev_hunk, { buffer = bufnr, desc = 'Go to [P]revious [H]unk' }) + vim.keymap.set('n', ']c', require('gitsigns').next_hunk, { buffer = bufnr, desc = 'Go to [N]ext [H]unk' }) + vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) end }, }, -- cgit v1.2.3-70-g09d2 From 986aa82cd63a104e0930c17f747518d6449ac11a Mon Sep 17 00:00:00 2001 From: Luiz Antonio Calliari Filho Date: Sun, 12 Mar 2023 20:45:26 -0300 Subject: FIX: Updating command description. --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index e3ddbd2..b4a7881 100644 --- a/init.lua +++ b/init.lua @@ -110,8 +110,8 @@ require('lazy').setup({ changedelete = { text = '~' }, }, on_attach = function(bufnr) - vim.keymap.set('n', '[c', require('gitsigns').prev_hunk, { buffer = bufnr, desc = 'Go to [P]revious [H]unk' }) - vim.keymap.set('n', ']c', require('gitsigns').next_hunk, { buffer = bufnr, desc = 'Go to [N]ext [H]unk' }) + vim.keymap.set('n', '[c', require('gitsigns').prev_hunk, { buffer = bufnr, desc = 'Go to Previous Hunk' }) + vim.keymap.set('n', ']c', require('gitsigns').next_hunk, { buffer = bufnr, desc = 'Go to Next Hunk' }) vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) end }, -- cgit v1.2.3-70-g09d2