nixos/lua/config_plugins/config_gitsigns.lua

26 lines
1.7 KiB
Lua

require('gitsigns').setup {
signcolumn = true,
numhl = true,
linehl = false,
current_line_blame = true,
word_diff = false,
on_attach = function(bufnr)
-- Setup keymaps
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[g', '<cmd>Gitsigns prev_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']g', '<cmd>Gitsigns next_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gd', '<cmd>Gitsigns diffthis<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gq', '<cmd>Gitsigns setqflist<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gl', '<cmd>Gitsigns setloclist<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>hp', '<cmd>Gitsigns preview_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>hs', '<cmd>Gitsigns stage_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>hr', '<cmd>Gitsigns reset_hunk<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>bs', '<cmd>Gitsigns stage_buffer<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>br', '<cmd>Gitsigns reset_buffer<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>bl', '<cmd>Gitsigns blame_line<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btn', '<cmd>Gitsigns toggle_numhl<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btl', '<cmd>Gitsigns toggle_linehl<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btc', '<cmd>Gitsigns toggle_current_line_blame<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>btw', '<cmd>Gitsigns toggle_word_diff<CR>', {})
end,
}