]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/coding.lua
nvim: add nvim-ts-context-commentstring to comment nested languages
[dotfiles.git] / nvim / lua / plugins / coding.lua
index eaa49cfb68e41b2ca832069939a7a290b37c34c0..55244d5912e9bbdaee302bbdffe952b84ffff212 100644 (file)
@@ -1,22 +1,22 @@
 ---@type LazySpec
 return {
   -- snippets
-  {
-    "L3MON4D3/LuaSnip",
-    -- disable luasnip bindings for <tab> and <s-tab>
+  { "l3mon4d3/luasnip",
+    build = "make install_jsregexp", -- optional
     dependencies = {
-      {
-        "honza/vim-snippets",
-        config = function()
-          require("luasnip.loaders.from_snipmate").lazy_load()
-          require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath("config") .. "/lua/snippets" })
-        end,
-      },
+      { "honza/vim-snippets", },
     },
+    config = function()
+      local snippets = vim.fn.stdpath("config").."/snippets"
+      require("luasnip.loaders.from_snipmate").load({ paths = { snippets }})
+      require("luasnip.loaders.from_lua").load({ paths = { snippets }})
+    end,
     keys = function()
       return {}
     end,
     opts = {
+      history = true,
+      delete_check_events = "TextChanged",
       store_selection_keys = "<Tab>",
     },
   },
@@ -145,31 +145,34 @@ return {
       }
     end,
   },
-  -- comments
   { "numToStr/Comment.nvim",
-    -- used to be what I use, but nvim will include commenting based on mini.comment
-    enabled = false ,
-    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,
   },
-  { "echasnovski/mini.comment", enabled = false },
-
-  {
-    "folke/lazydev.nvim",
+  { "folke/lazydev.nvim",
     ft = "lua",
     cmd = "LazyDev",
     opts = {
       library = {
         { path = "${3rd}/luv/library", words = { "vim%.uv" } },
-        { path = "LazyVim", words = { "LazyVim" } },
         { path = "snacks.nvim", words = { "Snacks" } },
         { path = "lazy.nvim", words = { "LazySpec" } },
       },