summaryrefslogtreecommitdiff
path: root/fnl/config/comment.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'fnl/config/comment.fnl')
-rw-r--r--fnl/config/comment.fnl28
1 files changed, 28 insertions, 0 deletions
diff --git a/fnl/config/comment.fnl b/fnl/config/comment.fnl
new file mode 100644
index 0000000..92df966
--- /dev/null
+++ b/fnl/config/comment.fnl
@@ -0,0 +1,28 @@
+;; Language aware commenting.
+(module config.comment
+ {autoload {util util}})
+
+(defn- get-type [ctx U]
+ (if (= ctx.ctype U.ctype.line)
+ :__default
+ :__multiline))
+
+(defn- get-location [ctx U]
+ (let [utils (require :ts_context_commentstring.utils)]
+ (if (= ctx.ctype U.ctype.block)
+ (utils.get_cursor_location)
+ (or (= ctx.cmotion U.cmotion.v) (= ctx.cmotion U.cmotion.V))
+ (utils.get_visual_start_location)
+ nil)))
+
+(defn- pre-hook [ctx]
+ (let [U (require :Comment.utils)
+ internal (require :ts_context_commentstring.internal)]
+ (internal.calculate_commentstring
+ {:key (get-type ctx U)
+ :location (get-location ctx U)})))
+
+(let [nvim-comment (util.load-plugin :Comment)]
+ (nvim-comment.setup
+ {:pre_hook (fn [ctx]
+ (pre-hook ctx))}))