5 require("gitsigns").setup({
8 change = { text = "┃" },
9 delete = { text = "_" },
10 topdelete = { text = "‾" },
11 changedelete = { text = "~" },
12 untracked = { text = "┆" },
16 change = { text = "┃" },
17 delete = { text = "_" },
18 topdelete = { text = "‾" },
19 changedelete = { text = "~" },
20 untracked = { text = "┆" },
22 signs_staged_enable = true,
23 signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
24 numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
25 linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
26 word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
31 attach_to_untracked = false,
32 current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
33 current_line_blame_opts = {
35 virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
37 ignore_whitespace = false,
38 virt_text_priority = 100,
41 current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
43 update_debounce = 100,
44 status_formatter = nil, -- Use default
45 max_file_length = 40000, -- Disable if file is longer than this (in lines)
47 -- Options passed to nvim_open_win
53 on_attach = function(bufnr)
54 local gitsigns = require("gitsigns")
56 local function map(mode, l, r, opts)
59 vim.keymap.set(mode, l, r, opts)
63 map("n", "]c", function()
65 vim.cmd.normal({ "]c", bang = true })
67 gitsigns.nav_hunk("next")
71 map("n", "[c", function()
73 vim.cmd.normal({ "[c", bang = true })
75 gitsigns.nav_hunk("prev")
80 map("n", "<leader>hs", gitsigns.stage_hunk)
81 map("n", "<leader>hr", gitsigns.reset_hunk)
83 map("v", "<leader>hs", function()
84 gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
87 map("v", "<leader>hr", function()
88 gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
91 map("n", "<leader>hS", gitsigns.stage_buffer)
92 map("n", "<leader>hR", gitsigns.reset_buffer)
93 map("n", "<leader>hp", gitsigns.preview_hunk)
94 map("n", "<leader>hi", gitsigns.preview_hunk_inline)
96 map("n", "<leader>hb", function()
97 gitsigns.blame_line({ full = true })
100 map("n", "<leader>hd", gitsigns.diffthis)
102 map("n", "<leader>hD", function()
103 gitsigns.diffthis("~")
106 map("n", "<leader>hQ", function()
107 gitsigns.setqflist("all")
109 map("n", "<leader>hq", gitsigns.setqflist)
112 map("n", "<leader>tb", gitsigns.toggle_current_line_blame)
113 map("n", "<leader>tw", gitsigns.toggle_word_diff)
116 map({ "o", "x" }, "ih", gitsigns.select_hunk)