diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2024-02-03 02:28:45 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2024-02-03 02:28:45 -0600 |
commit | 06404a4568f783221bb8cb8db9f6ad91f500a77c (patch) | |
tree | 9dee18934ce8e32b29ed8e8bf152fc0048a6d9e2 | |
parent | 130eede87d4dee6aee31157417f90f7bacb1525f (diff) |
refactor: git/telescope keymaps
-rw-r--r-- | lua/plugins/gitsigns.lua | 25 | ||||
-rw-r--r-- | lua/plugins/telescope.lua | 15 |
2 files changed, 27 insertions, 13 deletions
diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 086fb91..a40a3dc 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,18 +1,31 @@ return { 'lewis6991/gitsigns.nvim', opts = { - signs = { + signs = { add = { text = '+' }, change = { text = '~' }, delete = { text = '_' }, topdelete = { text = '‾' }, changedelete = { text = '~' }, }, - on_attach = function(bufnr) - local gitsigns = require('gitsigns') - vim.keymap.set('n', '[c', gitsigns.prev_hunk, { buffer = bufnr, desc = 'Go to Previous Hunk' }) - vim.keymap.set('n', ']c', gitsigns.next_hunk, { buffer = bufnr, desc = 'Go to Next Hunk' }) - vim.keymap.set('n', '<leader>ph', gitsigns.preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = true, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + on_attach = function(bufnr) + local gs = require('gitsigns') + + -- TODO: use this function for most of the keymaps across plugins? + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + map('n', '<leader>gp', gs.prev_hunk, { desc = '[g]it: [p]revious hunk' }) + map('n', '<leader>gn', gs.next_hunk, { desc = '[g]it: [n]ext hunk' }) + map('n', '<leader>gv', gs.preview_hunk, { desc = '[g]it: [v]iew hunk' }) + map('n', '<leader>gb', gs.toggle_current_line_blame, { desc = '[g]it: [b]lame toggle' }) end, }, } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 60084fb..7bb8ccf 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -35,12 +35,13 @@ return { previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) - vim.keymap.set('n', '<leader>gf', ts_builtin.git_files, { desc = 'Search [G]it [F]iles' }) - vim.keymap.set('n', '<leader>sf', ts_builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', '<leader>sh', ts_builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', '<leader>sw', ts_builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', '<leader>sg', ts_builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', '<leader>sd', ts_builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', '<leader>sr', ts_builtin.lsp_references, { desc = '[S]earch [R]eferences' }) + vim.keymap.set('n', '<leader>gf', ts_builtin.git_files, { desc = '[g]it: search [f]iles' }) + + vim.keymap.set('n', '<leader>sf', ts_builtin.find_files, { desc = '[s]earch [f]iles' }) + vim.keymap.set('n', '<leader>sh', ts_builtin.help_tags, { desc = '[s]earch [h]elp' }) + vim.keymap.set('n', '<leader>sw', ts_builtin.grep_string, { desc = '[s]earch current [w]ord' }) + vim.keymap.set('n', '<leader>sg', ts_builtin.live_grep, { desc = '[s]earch by [g]rep' }) + vim.keymap.set('n', '<leader>sd', ts_builtin.diagnostics, { desc = '[s]earch [d]iagnostics' }) + vim.keymap.set('n', '<leader>sr', ts_builtin.lsp_references, { desc = '[s]earch [r]eferences' }) end, } |