diff --git a/init.lua b/init.lua index 0b91d39c..44daae02 100644 --- a/init.lua +++ b/init.lua @@ -264,6 +264,65 @@ require('lazy').setup({ topdelete = { text = '‾' }, changedelete = { 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, + }, + auto_attach = true, + attach_to_untracked = false, + 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, + virt_text_priority = 100, + }, + current_line_blame_formatter = ', - ', + 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 function map(mode, lhs, rhs, opts) + opts = vim.tbl_extend('force', { noremap = true, silent = true }, opts or {}) + vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, opts) + end + + -- Navigation + map('n', ']c', "&diff ? ']c' : 'Gitsigns next_hunk'", { expr = true }) + map('n', '[c', "&diff ? '[c' : 'Gitsigns prev_hunk'", { expr = true }) + + -- Actions + map('n', 'hs', ':Gitsigns stage_hunk') + map('v', 'hs', ':Gitsigns stage_hunk') + map('n', 'hr', ':Gitsigns reset_hunk') + map('v', 'hr', ':Gitsigns reset_hunk') + map('n', 'hS', 'Gitsigns stage_buffer') + map('n', 'hu', 'Gitsigns undo_stage_hunk') + map('n', 'hR', 'Gitsigns reset_buffer') + map('n', 'hp', 'Gitsigns preview_hunk') + map('n', 'hb', 'lua require"gitsigns".blame_line{full=true}') + map('n', 'tb', 'Gitsigns toggle_current_line_blame') + map('n', 'hd', 'Gitsigns diffthis') + map('n', 'hD', 'lua require"gitsigns".diffthis("~")') + map('n', 'td', 'Gitsigns toggle_deleted') + + -- Text object + map('o', 'ih', ':Gitsigns select_hunk') + map('x', 'ih', ':Gitsigns select_hunk') + end, }, }, @@ -304,6 +363,7 @@ require('lazy').setup({ }, { mode = 'v' }) end, }, + -- -- NOTE: Plugins can specify dependencies. --