diff --git a/lua/znvim/options.lua b/lua/znvim/options.lua index 274af18..798bd52 100644 --- a/lua/znvim/options.lua +++ b/lua/znvim/options.lua @@ -18,6 +18,7 @@ vim.opt.number = true vim.opt.relativenumber = false vim.opt.numberwidth = 5 -- vim.opt.statuscolumn = "%C %4l %r" +vim.opt.signcolumn = "auto:1-2" vim.opt.wrap = false vim.opt.breakindent = true diff --git a/lua/znvim/plugins/git.lua b/lua/znvim/plugins/git.lua new file mode 100644 index 0000000..e23ee9d --- /dev/null +++ b/lua/znvim/plugins/git.lua @@ -0,0 +1,63 @@ +return { + + { -- gitsigns + "https://github.com/lewis6991/gitsigns.nvim", + event = "BufReadPre", + opts = { + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + signs_staged = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + attach_to_untracked = true, + on_attach = function(buffer) + local gitsigns = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + end + + map("n", "]h", gitsigns.next_hunk, "next hunk") + map("n", "[h", gitsigns.prev_hunk, "prev hunk") + + map("n", "gb", gitsigns.blame_line, "blame line") + map("n", "gB", function() gitsigns.blame_line({ full = true }) end, "full blame!") + map("n", "gp", gitsigns.preview_hunk, "look at hunk") + map("n", "gS", ":Gitsigns select_hunk", "select hunk") + map("n", "gd", gitsigns.diffthis, "diff this") + + map("n", "gsb", gitsigns.stage_buffer, "stage buffer") + map("n", "gsh", ":Gitsigns stage_hunk", "stage hunk (toggle)") + map("v", 'gsh', function() + gitsigns.stage_hunk({vim.fn.line('.'), vim.fn.line('v')}) + end, "stage selected hunk") + map("n", "gsu", ":Gitsigns undo_stage_hunk", "undo last stage hunk") + + map("n", "grb", "Gitsigns reset_buffer", "reset buffer") + map("n", "grh", "Gitsigns reset_hunk", "reset hunk") + map("v", 'grh', function() + gitsigns.reset_hunk({vim.fn.line('.'), vim.fn.line('v')}) + end, "reset selected hunk") + + map("n", "gtl", "Gitsigns toggle_linehl", "toggle line highlight") + map("n", "gtn", "Gitsigns toggle_numhl", "toggle line number highlight") + map("n", "gts", "Gitsigns toggle_signs", "toggle signs") + map("n", "gtw", "Gitsigns toggle_word_diff", "toggle word diff") + map("n", "gtd", "Gitsigns toggle_deleted", "toggle deleted lines") + map("n", "gtb", "Gitsigns toggle_current_line_blame", "toggle current line blame") + end, + }, + }, + +}