diff options
author | Yigit Sever | 2023-06-21 04:33:34 +0300 |
---|---|---|
committer | Yigit Sever | 2023-06-21 04:34:52 +0300 |
commit | 236a0d75ac4b83b6c4cb5b38d0d79a4c1362b949 (patch) | |
tree | 1aea0887491f4d23568eed74e7be293d15089e60 /.config/nvim/lua | |
parent | d14afaf4752872d1006809f683574d48f668a3e0 (diff) | |
download | dotfiles-236a0d75ac4b83b6c4cb5b38d0d79a4c1362b949.tar.gz dotfiles-236a0d75ac4b83b6c4cb5b38d0d79a4c1362b949.tar.bz2 dotfiles-236a0d75ac4b83b6c4cb5b38d0d79a4c1362b949.zip |
nvim: update gitsigns config
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/plugin_settings.lua | 143 |
1 files changed, 80 insertions, 63 deletions
diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index 48c25f2..1025c00 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua | |||
@@ -461,69 +461,86 @@ require 'colorizer'.setup() | |||
461 | -- gitsigns.nvim {{{ -- | 461 | -- gitsigns.nvim {{{ -- |
462 | 462 | ||
463 | require('gitsigns').setup { | 463 | require('gitsigns').setup { |
464 | signs = { | 464 | signs = { |
465 | add = {hl = 'GitSignsAdd' , text = '│', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'}, | 465 | add = { text = '│' }, |
466 | change = {hl = 'GitSignsChange', text = '│', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, | 466 | change = { text = '│' }, |
467 | delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, | 467 | delete = { text = '_' }, |
468 | topdelete = {hl = 'GitSignsDelete', text = '‾', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'}, | 468 | topdelete = { text = '‾' }, |
469 | changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'}, | 469 | changedelete = { text = '~' }, |
470 | 470 | untracked = { text = '┆' }, | |
471 | }, | 471 | }, |
472 | signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` | 472 | signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` |
473 | numhl = false, -- Toggle with `:Gitsigns toggle_numhl` | 473 | numhl = false, -- Toggle with `:Gitsigns toggle_numhl` |
474 | linehl = false, -- Toggle with `:Gitsigns toggle_linehl` | 474 | linehl = false, -- Toggle with `:Gitsigns toggle_linehl` |
475 | word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` | 475 | word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` |
476 | keymaps = { | 476 | watch_gitdir = { |
477 | -- Default keymap options | 477 | follow_files = true |
478 | noremap = true, | 478 | }, |
479 | 479 | attach_to_untracked = true, | |
480 | ['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns.actions\".next_hunk()<CR>'"}, | 480 | current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` |
481 | ['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns.actions\".prev_hunk()<CR>'"}, | 481 | current_line_blame_opts = { |
482 | 482 | virt_text = true, | |
483 | ['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>', | 483 | virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' |
484 | ['v <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>', | 484 | delay = 1000, |
485 | ['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>', | 485 | ignore_whitespace = false, |
486 | ['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>', | 486 | }, |
487 | ['v <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>', | 487 | current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>', |
488 | ['n <leader>hR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>', | 488 | sign_priority = 6, |
489 | ['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>', | 489 | update_debounce = 100, |
490 | ['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>', | 490 | status_formatter = nil, -- Use default |
491 | ['n <leader>hS'] = '<cmd>lua require"gitsigns".stage_buffer()<CR>', | 491 | max_file_length = 40000, -- Disable if file is longer than this (in lines) |
492 | ['n <leader>hU'] = '<cmd>lua require"gitsigns".reset_buffer_index()<CR>', | 492 | preview_config = { |
493 | 493 | -- Options passed to nvim_open_win | |
494 | -- Text objects | 494 | border = 'single', |
495 | ['o ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>', | 495 | style = 'minimal', |
496 | ['x ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>' | 496 | relative = 'cursor', |
497 | }, | 497 | row = 0, |
498 | watch_gitdir = { | 498 | col = 1 |
499 | interval = 1000, | 499 | }, |
500 | follow_files = true | 500 | yadm = { |
501 | }, | 501 | enable = true |
502 | attach_to_untracked = true, | 502 | }, |
503 | current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` | 503 | |
504 | current_line_blame_opts = { | 504 | on_attach = function(bufnr) |
505 | virt_text = true, | 505 | local gs = package.loaded.gitsigns |
506 | virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' | 506 | |
507 | delay = 1000, | 507 | local function map(mode, l, r, opts) |
508 | }, | 508 | opts = opts or {} |
509 | current_line_blame_formatter_opts = { | 509 | opts.buffer = bufnr |
510 | relative_time = false | 510 | vim.keymap.set(mode, l, r, opts) |
511 | }, | 511 | end |
512 | sign_priority = 6, | 512 | |
513 | update_debounce = 100, | 513 | -- Navigation |
514 | status_formatter = nil, -- Use default | 514 | map('n', ']c', function() |
515 | max_file_length = 40000, | 515 | if vim.wo.diff then return ']c' end |
516 | preview_config = { | 516 | vim.schedule(function() gs.next_hunk() end) |
517 | -- Options passed to nvim_open_win | 517 | return '<Ignore>' |
518 | border = 'single', | 518 | end, {expr=true}) |
519 | style = 'minimal', | 519 | |
520 | relative = 'cursor', | 520 | map('n', '[c', function() |
521 | row = 0, | 521 | if vim.wo.diff then return '[c' end |
522 | col = 1 | 522 | vim.schedule(function() gs.prev_hunk() end) |
523 | }, | 523 | return '<Ignore>' |
524 | yadm = { | 524 | end, {expr=true}) |
525 | enable = true | 525 | |
526 | }, | 526 | -- Actions |
527 | map('n', '<leader>hs', gs.stage_hunk) | ||
528 | map('n', '<leader>hr', gs.reset_hunk) | ||
529 | map('v', '<leader>hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) | ||
530 | map('v', '<leader>hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) | ||
531 | map('n', '<leader>hS', gs.stage_buffer) | ||
532 | map('n', '<leader>hu', gs.undo_stage_hunk) | ||
533 | map('n', '<leader>hR', gs.reset_buffer) | ||
534 | map('n', '<leader>hp', gs.preview_hunk) | ||
535 | map('n', '<leader>hb', function() gs.blame_line{full=true} end) | ||
536 | map('n', '<leader>tb', gs.toggle_current_line_blame) | ||
537 | map('n', '<leader>hd', gs.diffthis) | ||
538 | map('n', '<leader>hD', function() gs.diffthis('~') end) | ||
539 | map('n', '<leader>td', gs.toggle_deleted) | ||
540 | |||
541 | -- Text object | ||
542 | map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>') | ||
543 | end | ||
527 | } | 544 | } |
528 | 545 | ||
529 | -- }}} gitsigns.nvim -- | 546 | -- }}} gitsigns.nvim -- |