From 2a94573f54c69a9af7536586ab2c03eb88bda5e7 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Fri, 5 Jan 2024 01:50:20 +0100 Subject: Refactor --- fnl/plugins/comment.fnl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 fnl/plugins/comment.fnl (limited to 'fnl/plugins/comment.fnl') diff --git a/fnl/plugins/comment.fnl b/fnl/plugins/comment.fnl new file mode 100644 index 0000000..66abb33 --- /dev/null +++ b/fnl/plugins/comment.fnl @@ -0,0 +1,35 @@ +;; Language aware commenting. + +(local opts {:toggler {;; Line-comment toggle keymap + :line :mcc + ;; Block-comment toggle keymap + :block :mbc} + ;; LHS of operator-pending mappings in NORMAL and VISUAL mode + :opleader {;; Line-comment keymap + :line :mc + ;; Block-comment keymap + :block :mb} + ;; LHS of extra mappings + :extra {;; Add comment on the line above + :above :mcO + ;; Add comment on the line below + :below :mco + ;; Add comment at the end of line + :eol :mcA}}) + +(local user-cmds [[:CommentNormal + (lambda [] + (let [comment-api (require :Comment.api)] + (comment-api.toggle.linewise.current))) + {:nargs 0}] + [:CommentVisual + (lambda [] + (let [comment-api (require :Comment.api)] + (comment-api.toggle.linewise (vim.fn.visualmode)))) + {:nargs 0}]]) + +(fn init [] + (let [cmds (require :util.cmds)] + (cmds.create-user-cmds user-cmds))) + +{1 :numToStr/Comment.nvim :event :BufReadPost : inti : opts} -- cgit v1.2.3-70-g09d2