From d3833a02c1ebb0733387edb7287a830a2f141728 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 25 Feb 2025 22:33:21 +0000 Subject: [PATCH] nvim: add nvim-ts-context-commentstring to comment nested languages --- nvim/lua/plugins/coding.lua | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index 1be8db3..55244d5 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -146,16 +146,26 @@ return { end, }, { "numToStr/Comment.nvim", - opts = { - toggler = { - line = "gcc", - block = "gbb", - }, - mappings = { - basic = true, - extra = true, - }, + dependencies = { + { "JoosepAlviste/nvim-ts-context-commentstring", -- nested language commenting (f.ex markdown code blocks) + opts = { enable_autocmd = false, }, + } }, + opts = function(_, opts) + local tscci = require('ts_context_commentstring.integrations.comment_nvim') + vim.tbl_deep_extend('force', opts, { + toggler = { + line = "gcc", + block = "gbb", + }, + mappings = { + basic = true, + extra = true, + }, + pre_hook = tscci.create_pre_hook() + }) + return opts + end, }, { "folke/lazydev.nvim", ft = "lua", -- 2.48.1