diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-12-11 20:46:32 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-12-11 20:47:59 +0100 |
commit | f22f1723c01b56da14ae1de3491a78af1bc4c464 (patch) | |
tree | 030411c811d3474c4b322eca29d1bf8e96b7511f /private_dot_config/nvim/lua/git.lua | |
parent | d8713792f93473fe14e01d151529fb6ef139448f (diff) |
Dot files with `chezmoi`
Diffstat (limited to 'private_dot_config/nvim/lua/git.lua')
-rw-r--r-- | private_dot_config/nvim/lua/git.lua | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/private_dot_config/nvim/lua/git.lua b/private_dot_config/nvim/lua/git.lua new file mode 100644 index 0000000..da6bbdd --- /dev/null +++ b/private_dot_config/nvim/lua/git.lua @@ -0,0 +1,65 @@ +require('gitsigns').setup { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = '-' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + 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('n', ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '<Ignore>' + end, {expr=true}) + + map('n', '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '<Ignore>' + end, {expr=true}) + + map('n', 'hs', gs.stage_hunk) + map('v', 'hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('n', 'hS', gs.stage_buffer) + map('n', 'hu', gs.undo_stage_hunk) + map('n', 'hp', gs.preview_hunk) + map('n', 'hB', gs.blame_line) + end +} |