added gitsigns

This commit is contained in:
polamid23 2023-07-13 11:32:41 +02:00
parent 5e33dbc205
commit 610575babe
3 changed files with 44 additions and 3 deletions

View file

@ -2,8 +2,9 @@
"LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"copilot.vim": { "branch": "release", "commit": "a4a6d6b3f9e284e7f5c849619e06cd228cad8abd" },
"gitsigns.nvim": { "branch": "main", "commit": "48c3ae8ec74cb83f9570ceb0c5ab8217db7a2220" },
"gruvbox": { "branch": "master", "commit": "2b5b1f777f0583ffb39086d6c16f39e6e37459c0" },
"lazy.nvim": { "branch": "main", "commit": "5af331ea65418dc9361769891921fdee4bcc837a" },
"lazy.nvim": { "branch": "main", "commit": "14d76aac4bd3ff07c1fca074c210f28f766a931e" },
"lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" },
"mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" },

40
lua/plugin/gitsigns.lua Normal file
View file

@ -0,0 +1,40 @@
require('gitsigns').setup {
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- map leader gj to go to next hunk
map('n', '<leader>gj', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, { expr = true })
-- map leader gk to go to previous hunk
map('n', '<leader>gk', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, { expr = true })
map('n', '<leader>gp', gs.preview_hunk)
map('n', '<leader>gs', gs.stage_hunk)
map('v', '<leader>gs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
map('n', '<leader>gu', gs.reset_hunk)
-- nnoremap <leader>glf :!smerge log %<CR>
map('n', '<leader>glf', function()
vim.fn.system('smerge log ' .. vim.fn.expand('%'))
end)
-- nnoremap <leader>gbf :!smerge blame % line('.')<CR>
map('n', '<leader>gbf', function()
vim.fn.system('smerge blame ' .. vim.fn.expand('%') .. ' ' .. vim.fn.line('.'))
end)
end
}

View file

@ -46,10 +46,10 @@ require("lazy").setup({
{ 'mhinz/vim-startify' },
-- themes
{ 'gruvbox-community/gruvbox' },
-- gitsigns
{ 'lewis6991/gitsigns.nvim' },
}
},
}, opts)