]> git.rmz.io Git - dotfiles.git/commitdiff
nvim: add nvim-ts-context-commentstring to comment nested languages
authorSamir Benmendil <me@rmz.io>
Tue, 25 Feb 2025 22:33:21 +0000 (22:33 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 2 Mar 2025 16:17:49 +0000 (16:17 +0000)
nvim/lua/plugins/coding.lua

index 1be8db3160c33f91c6379a36dce5ecb7391f4068..55244d5912e9bbdaee302bbdffe952b84ffff212 100644 (file)
@@ -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",