From 6b6e03d16b85c221b2f8b6e062f23f00c59faa23 Mon Sep 17 00:00:00 2001 From: Daniil Tsivinsky Date: Fri, 8 Mar 2024 23:59:23 +0300 Subject: [PATCH] neovim: fix commentstring --- neovim/.config/nvim/after/plugin/comment.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/neovim/.config/nvim/after/plugin/comment.lua b/neovim/.config/nvim/after/plugin/comment.lua index edc4899..43d7c6f 100644 --- a/neovim/.config/nvim/after/plugin/comment.lua +++ b/neovim/.config/nvim/after/plugin/comment.lua @@ -1,12 +1,16 @@ +local U = require("Comment.utils") + +local ctype_to_commentstring = { + [U.ctype.linewise] = "__default", + [U.ctype.blockwise] = "__multiline", +} + require("Comment").setup({ pre_hook = function(ctx) -- Only calculate commentstring for tsx filetypes if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then - local U = require("Comment.utils") - -- Detemine whether to use linewise or blockwise commentstring - -- local type = ctx.ctype == U.ctype.line and "__default" or "__multiline" - local type = "__default" + local type = ctype_to_commentstring[ctx.ctype] -- Determine the location where to calculate commentstring from local location = nil