diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-03-12 22:50:12 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-03-12 22:50:12 +0800 |
commit | 3ad034a1b5755bd5d8ebed71637dedb9089a7dce (patch) | |
tree | 228aed35af429f3819b897da2dd3b12742063f7d /store/home/config/nvim/lua/setup/plugins/gitsigns.lua | |
parent | 117afbc9af2cd4fd515d7fdbda8a1fa44c3d8a74 (diff) | |
download | crupest-main.tar.gz crupest-main.tar.bz2 crupest-main.zip |
Diffstat (limited to 'store/home/config/nvim/lua/setup/plugins/gitsigns.lua')
-rw-r--r-- | store/home/config/nvim/lua/setup/plugins/gitsigns.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/store/home/config/nvim/lua/setup/plugins/gitsigns.lua b/store/home/config/nvim/lua/setup/plugins/gitsigns.lua new file mode 100644 index 0000000..957c661 --- /dev/null +++ b/store/home/config/nvim/lua/setup/plugins/gitsigns.lua @@ -0,0 +1,40 @@ +local function setup() + local gitsigns = require('gitsigns') + + gitsigns.setup { + on_attach = function(bufnr) + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') + end + end) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', '<leader>gc', gitsigns.preview_hunk) + map('n', '<leader>gt', gitsigns.toggle_deleted) + map('n', '<leader>gd', gitsigns.diffthis) + map('n', '<leader>gb', function() gitsigns.blame_line { full = true } end) + end + } +end + +return { + setup = setup +} |