diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-04-04 22:35:15 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-04-04 22:35:15 +0200 |
commit | f76a4f1eb665e223be19f200336409a3de48f5bb (patch) | |
tree | 9c75f4540f627e7f604a9e8b8fedda287bb6e91f /fnl/config | |
parent | 6aebac1fcb09417388d96c28d55cbf69b58b940c (diff) |
feat(comment): add fnl config
Diffstat (limited to 'fnl/config')
-rw-r--r-- | fnl/config/ncomment.fnl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fnl/config/ncomment.fnl b/fnl/config/ncomment.fnl new file mode 100644 index 0000000..68d4c97 --- /dev/null +++ b/fnl/config/ncomment.fnl @@ -0,0 +1,26 @@ +;; Language aware commenting. +(module config.ncomment + {autoload {util util}}) + + +(defn- get-type [ctx U] + (or (and (= ctx.ctype U.ctype.line) :__default) :__multiline)) + +(defn- get-location [ctx U] + (if (= ctx.ctype U.ctype.block) + ((require :ts_context_commentstring.utils).get_cursor_location) + (or (= ctx.motion U.motion.v) (= ctx.motion U.cmotion.V)) + ((require :ts_context_commentstring.utils).get_visual_start_location) + (nil))) + +(defn- pre-hook [ctx] + (let [U (require :Comment.utils)] + ((require :ts_context_commentstring.internal).calculate_commentstring { + :key (get-type ctx U) + :location (get-location ctx U)}))) + +(let [(ok? ncomment) util.load-plugin :Comment] + (when ok? + (ncomment.setup + {:pre_hook (fn [ctx] + (pre-hook ctx))}))) |