Parent directory

git.lua

1906 bytes
 1require("gitsigns").setup({
 2	signs = {
 3		add = { text = "+" },
 4		change = { text = "~" },
 5		delete = { text = "_" },
 6		topdelete = { text = "‾" },
 7		changedelete = { text = "~" },
 8		untracked = { text = "┆" },
 9	},
10	signcolumn = true, -- :Gitsigns toggle_signs
11	numhl = false, -- :Gitsigns toggle_numhl
12	linehl = false, -- :Gitsigns toggle_linehl
13	word_diff = false, -- :Gitsigns toggle_word_diff
14	watch_gitdir = {
15		follow_files = true,
16	},
17	attach_to_untracked = true,
18	current_line_blame = true,
19	current_line_blame_opts = {
20		virt_text = true,
21		virt_text_pos = "right_align", -- 'eol' | 'overlay' | 'right_align'
22		delay = 100,
23		ignore_whitespace = false,
24	},
25	current_line_blame_formatter = "<abbrev_sha> - <author> <author_time:%Y-%m-%d>",
26	sign_priority = 6,
27	update_debounce = 100,
28	status_formatter = nil, -- Use default
29	max_file_length = 40000, -- Disable if file is longer than this (in lines)
30	preview_config = {
31		-- Options passed to nvim_open_win
32		border = "single",
33		style = "minimal",
34		relative = "cursor",
35		row = 0,
36		col = 1,
37	},
38	on_attach = function(bufnr)
39		local gs = package.loaded.gitsigns
40
41		local function map(mode, l, r, opts)
42			opts = opts or {}
43			opts.buffer = bufnr
44			vim.keymap.set(mode, l, r, opts)
45		end
46
47		-- Navigation
48		map("n", "]c", function()
49			if vim.wo.diff then
50				return "]c"
51			end
52			vim.schedule(function()
53				gs.next_hunk()
54			end)
55			return "<Ignore>"
56		end, { expr = true })
57
58		map("n", "[c", function()
59			if vim.wo.diff then
60				return "[c"
61			end
62			vim.schedule(function()
63				gs.prev_hunk()
64			end)
65			return "<Ignore>"
66		end, { expr = true })
67
68		-- Actions
69		map("n", "<leader>hs", gs.stage_hunk)
70		map("n", "<leader>hu", gs.undo_stage_hunk)
71		map("n", "<leader>hS", gs.stage_buffer)
72		map("n", "<leader>hR", gs.reset_buffer)
73		map("n", "<leader>tb", gs.toggle_current_line_blame)
74		map("n", "<leader>td", gs.toggle_deleted)
75	end,
76})