add gitsigns
This commit is contained in:
parent
09aa20cf59
commit
8f05b02766
2 changed files with 65 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
"fidget.nvim": { "branch": "main", "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
|
||||
"fzf-lua": { "branch": "main", "commit": "bde73a6886b607246095aa59f396de5e0d036890" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "0d797daee85366bc242580e352a4f62d67557b84" },
|
||||
"gruvbox.nvim": { "branch": "main", "commit": "334d5fd49fc8033f26408425366c66c6390c57bb" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
|
||||
|
|
|
|||
64
lua/plugins/gitsigns.lua
Normal file
64
lua/plugins/gitsigns.lua
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
return {
|
||||
'lewis6991/gitsigns.nvim',
|
||||
event = 'BufReadPre',
|
||||
|
||||
---@module 'gitsigns'
|
||||
---@type GitSigns.Config
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '▁' },
|
||||
topdelete = { text = '▔' },
|
||||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' },
|
||||
},
|
||||
signs_staged = {
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '▁' },
|
||||
topdelete = { text = '▔' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
signs_staged_enable = true,
|
||||
current_line_blame = false,
|
||||
|
||||
on_attach = function(bufnr)
|
||||
local gs = require('gitsigns')
|
||||
local function map(mode, lhs, rhs, desc)
|
||||
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
map('n', ']h', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({ ']c', bang = true })
|
||||
else
|
||||
gs.nav_hunk('next')
|
||||
end
|
||||
end, 'Next hunk')
|
||||
|
||||
map('n', '[h', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({ '[c', bang = true })
|
||||
else
|
||||
gs.nav_hunk('prev')
|
||||
end
|
||||
end, 'Prev hunk')
|
||||
|
||||
map('n', '<leader>hs', function()
|
||||
gs.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
||||
end, 'Stage hunk (selection)')
|
||||
|
||||
map('v', '<leader>hr', function()
|
||||
gs.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
||||
end, 'Reset hunk (selection)')
|
||||
|
||||
map('n', '<leader>hp', gs.preview_hunk, 'Preview hunk')
|
||||
map('n', '<leader>hd', gs.diffthis, 'Diff this')
|
||||
map('n', '<leader>hD', function() gs.diffthis('~') end, 'Diff this (last commit)')
|
||||
|
||||
map('n', '<leader>gb', gs.toggle_current_line_blame, 'Toggle line blame')
|
||||
map('n', '<leader>gB', gs.blame, 'Blame buffer')
|
||||
end
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue