From b504c932e613cf782a4346393eff1fc7ce2537f9 Mon Sep 17 00:00:00 2001 From: jdhao Date: Thu, 8 Sep 2022 20:31:33 +0800 Subject: use gitsigns instead of signify --- lua/config/gitsigns.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lua/config/gitsigns.lua (limited to 'lua/config/gitsigns.lua') diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua new file mode 100644 index 0000000..0543412 --- /dev/null +++ b/lua/config/gitsigns.lua @@ -0,0 +1,44 @@ +local gs = require "gitsigns" + +gs.setup { + signs = { + add = { hl = "GitSignsAdd", text = "+", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "~", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "‾", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "│", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + word_diff = true, -- Toggle with `:Gitsigns toggle_word_diff` + on_attach = function(bufnr) + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + gs.next_hunk() + end) + return "" + end, { expr = true, desc = 'next hunk' }) + + map("n", "[c", function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + gs.prev_hunk() + end) + return "" + end, { expr = true, desc = 'previous hunk' }) + + -- Actions + map("n", "hp", gs.preview_hunk) + map("n", "hb", function() gs.blame_line { full = true } end) + end, +} -- cgit v1.2.3