summaryrefslogtreecommitdiff
path: root/fnl
diff options
context:
space:
mode:
Diffstat (limited to 'fnl')
-rw-r--r--fnl/plugins/editor/gitsigns.fnl82
1 files changed, 54 insertions, 28 deletions
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 "<cmd>Gitsigns diffthis HEAD<cr>" :desc "Gitsigns diff"}
- {1 :<leader>gR
- 2 "<cmd>lua require 'gitsigns'.reset_buffer()<cr>"
- :desc "Reset Buffer"}
- {1 :<leader>gd 2 "<cmd>Gitsigns diffthis HEAD<cr>" :desc :Diff}
- {1 :<leader>gj
- 2 "<cmd>lua require 'gitsigns'.next_hunk()<cr>"
- :desc "Next Hunk"}
- {1 :<leader>gk
- 2 "<cmd>lua require 'gitsigns'.prev_hunk()<cr>"
- :desc "Prev Hunk"}
- {1 :<leader>gl
- 2 "<cmd>lua require 'gitsigns'.blame_line()<cr>"
- :desc :Blame}
- {1 :<leader>gp
- 2 "<cmd>lua require 'gitsigns'.preview_hunk()<cr>"
- :desc "Preview Hunk"}
- {1 :<leader>gr
- 2 "<cmd>lua require 'gitsigns'.reset_hunk()<cr>"
- :desc "Reset Hunk"}
- {1 :<leader>gs
- 2 "<cmd>lua require 'gitsigns'.stage_hunk()<cr>"
- :desc "Stage Hunk"}
- {1 :<leader>gu
- 2 "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>"
- :desc "Undo Stage Hunk"}])
+(local mappings [[:n
+ :mq
+ "<cmd>Gitsigns diffthis HEAD<cr>"
+ {:desc "Gitsigns diff"}]
+ [:n
+ :<leader>gR
+ "<cmd>lua require 'gitsigns'.reset_buffer()<cr>"
+ {:desc "Reset Buffer"}]
+ [:n
+ :<leader>gd
+ "<cmd>Gitsigns diffthis HEAD<cr>"
+ {:desc :Diff}]
+ [:n
+ :<leader>gj
+ "<cmd>lua require 'gitsigns'.next_hunk()<cr>"
+ {:desc "Next Hunk"}]
+ [:n
+ :<leader>gk
+ "<cmd>lua require 'gitsigns'.prev_hunk()<cr>"
+ {:desc "Prev Hunk"}]
+ [:n
+ :<leader>gl
+ "<cmd>lua require 'gitsigns'.blame_line()<cr>"
+ {:desc :Blame}]
+ [:n
+ :<leader>gp
+ "<cmd>lua require 'gitsigns'.preview_hunk()<cr>"
+ {:desc "Preview Hunk"}]
+ [:n
+ :<leader>gr
+ "<cmd>lua require 'gitsigns'.reset_hunk()<cr>"
+ {:desc "Reset Hunk"}]
+ [:n
+ :<leader>gs
+ "<cmd>lua require 'gitsigns'.stage_hunk()<cr>"
+ {:desc "Stage Hunk"}]
+ [:n
+ :<leader>gu
+ "<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>"
+ {:desc "Undo Stage Hunk"}]
+ [[:o :x]
+ :<leader>gn
+ ":<C-U>Gitsigns select_hunk<CR>"
+ {: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}