From 1cf7262b7b051861936937d57e7cb9b8b27f48f3 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 13 Feb 2023 22:18:18 +0100 Subject: Update gitsigns --- fnl/plugins/editor/gitsigns.fnl | 82 +++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 28 deletions(-) (limited to 'fnl/plugins') diff --git a/fnl/plugins/editor/gitsigns.fnl b/fnl/plugins/editor/gitsigns.fnl index 66c3ca4..e0551e6 100644 --- a/fnl/plugins/editor/gitsigns.fnl +++ b/fnl/plugins/editor/gitsigns.fnl @@ -1,31 +1,55 @@ ;; Add git signs to source files. -(local keys [{1 :mq 2 "Gitsigns diffthis HEAD" :desc "Gitsigns diff"} - {1 :gR - 2 "lua require 'gitsigns'.reset_buffer()" - :desc "Reset Buffer"} - {1 :gd 2 "Gitsigns diffthis HEAD" :desc :Diff} - {1 :gj - 2 "lua require 'gitsigns'.next_hunk()" - :desc "Next Hunk"} - {1 :gk - 2 "lua require 'gitsigns'.prev_hunk()" - :desc "Prev Hunk"} - {1 :gl - 2 "lua require 'gitsigns'.blame_line()" - :desc :Blame} - {1 :gp - 2 "lua require 'gitsigns'.preview_hunk()" - :desc "Preview Hunk"} - {1 :gr - 2 "lua require 'gitsigns'.reset_hunk()" - :desc "Reset Hunk"} - {1 :gs - 2 "lua require 'gitsigns'.stage_hunk()" - :desc "Stage Hunk"} - {1 :gu - 2 "lua require 'gitsigns'.undo_stage_hunk()" - :desc "Undo Stage Hunk"}]) +(local mappings [[:n + :mq + "Gitsigns diffthis HEAD" + {:desc "Gitsigns diff"}] + [:n + :gR + "lua require 'gitsigns'.reset_buffer()" + {:desc "Reset Buffer"}] + [:n + :gd + "Gitsigns diffthis HEAD" + {:desc :Diff}] + [:n + :gj + "lua require 'gitsigns'.next_hunk()" + {:desc "Next Hunk"}] + [:n + :gk + "lua require 'gitsigns'.prev_hunk()" + {:desc "Prev Hunk"}] + [:n + :gl + "lua require 'gitsigns'.blame_line()" + {:desc :Blame}] + [:n + :gp + "lua require 'gitsigns'.preview_hunk()" + {:desc "Preview Hunk"}] + [:n + :gr + "lua require 'gitsigns'.reset_hunk()" + {:desc "Reset Hunk"}] + [:n + :gs + "lua require 'gitsigns'.stage_hunk()" + {:desc "Stage Hunk"}] + [:n + :gu + "lua require 'gitsigns'.undo_stage_hunk()" + {:desc "Undo Stage Hunk"}] + [[:o :x] + :gn + ":Gitsigns select_hunk" + {:desc "GitSigns Select Hunk"}]]) + +(fn on-attach [bufnr] + (each [_ mapping (ipairs mappings)] + (match mapping + [mode key cmd desc] + (vim.keymap.set mode key cmd (vim.tbl_extend :force {:buffer bufnr} desc))))) (local signs {:add {:hl :GitSignsAdd :text "|" @@ -70,6 +94,8 @@ :relative :cursor :row 0 :col 1} - :yadm {:enable false}}) + :yadm {:enable false} + :on_attach (fn [bufnr] + (on-attach bufnr))}) -{1 :lewis6991/gitsigns.nvim :event :BufReadPost : keys : opts} +{1 :lewis6991/gitsigns.nvim :event [:BufReadPost :BufNewFile] : opts} -- cgit v1.2.3-70-g09d2