summaryrefslogtreecommitdiffstats
path: root/lua/user/comment.lua
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-03-07 14:43:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-03-07 14:43:57 +0100
commit596823bc99e656d3913ad7fe7f6c0f27a30c0110 (patch)
tree9ddf40caf018cc630d445db327d7b8d52994f921 /lua/user/comment.lua
parentcbcab8684e06379c9f5c51cfc9cac68d8684fe0c (diff)
downloadvim-596823bc99e656d3913ad7fe7f6c0f27a30c0110.zip
vim-596823bc99e656d3913ad7fe7f6c0f27a30c0110.tar.gz
switch to neovim + lua
Diffstat (limited to 'lua/user/comment.lua')
-rw-r--r--lua/user/comment.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/lua/user/comment.lua b/lua/user/comment.lua
new file mode 100644
index 0000000..7f8870f
--- /dev/null
+++ b/lua/user/comment.lua
@@ -0,0 +1,23 @@
+local status_ok, comment = pcall(require, "Comment")
+if not status_ok then
+ return
+end
+
+comment.setup {
+ pre_hook = function(ctx)
+ local U = require "Comment.utils"
+
+ local location = nil
+ if ctx.ctype == U.ctype.block then
+ location = require("ts_context_commentstring.utils").get_cursor_location()
+ elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
+ location = require("ts_context_commentstring.utils").get_visual_start_location()
+ end
+
+ return require("ts_context_commentstring.internal").calculate_commentstring {
+ key = ctx.ctype == U.ctype.line and "__default" or "__multiline",
+ location = location,
+ }
+ end,
+}
+