]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/coding.lua
lazyvim: remove nvim-cmp config
[dotfiles.git] / nvim / lua / plugins / coding.lua
index a765a79ae258c206207843c4ab7fa35242f035d7..985ccf077398c5b9c508d3508d76f146b51d6e48 100644 (file)
@@ -4,51 +4,75 @@ return {
   {
     "L3MON4D3/LuaSnip",
     -- disable luasnip bindings for <tab> and <s-tab>
+    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,
+      },
+    },
     keys = function()
       return {}
     end,
+    opts = {
+      store_selection_keys = "<Tab>",
+    },
   },
 
-  -- auto completion
+  -- auto pairs
   {
-    "hrsh7th/nvim-cmp",
-    ---@param opts cmp.ConfigSchema
-    opts = function(_, opts)
-      local has_words_before = function()
-        unpack = unpack or table.unpack
-        local line, col = unpack(vim.api.nvim_win_get_cursor(0))
-        return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
-      end
-
-      local cmp = require("cmp")
-      local luasnip = require("luasnip")
+    "echasnovski/mini.pairs",
+  },
 
-      opts.completion = vim.tbl_extend("force", opts.completion, {
-        completeopt = "menu,menuone,noselect",
-      })
-      --TODO: review if I want to keep any of LazyVim's mappings
-      opts.mapping = vim.tbl_extend("force", opts.mapping, {
-        ["<Tab>"] = cmp.mapping(function(fallback)
-          if cmp.visible() then
-            cmp.select_next_item()
-          elseif luasnip.expand_or_jumpable() then
-            luasnip.expand_or_jump()
-          elseif has_words_before() then
-            cmp.complete()
-          else
-            fallback()
-          end
-        end, { "i", "s" }),
-        ["<S-Tab>"] = cmp.mapping(function(fallback)
-          if cmp.visible() then
-            cmp.select_prev_item()
-          elseif luasnip.jumpable(-1) then
-            luasnip.jump(-1)
-          else
-            fallback()
-          end
-        end, { "i", "s" }),
-      })
+  -- surround
+  {
+    "echasnovski/mini.surround",
+    keys = function()
+      -- HACK: use function to disable merging with LazyVim's keys definition
+      return {
+        { "ys", desc = "Add surrounding", "n" },
+        { "S", desc = "Add surrounding", "x" },
+        { "ds", desc = "Delete surrounding" },
+        { "cs", desc = "Change surrounding" },
+        { "yss", "ys_", remap = true },
+      }
     end,
+    opts = {
+      mappings = {
+        -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings
+        -- see: :h MiniSurround-vim-surround-config
+        add = "ys",
+        delete = "ds",
+        find = "",
+        find_left = "",
+        highlight = "",
+        replace = "cs",
+        update_n_lines = "",
+      },
+    },
+    config = function(_, opts)
+      require("mini.surround").setup(opts)
+      -- remap visual
+      vim.keymap.del("x", "ys", { silent = true })
+      vim.keymap.set("x", "S", [[:<C-u>lua MiniSurround.add('visual')<CR>]], { silent = true })
+    end,
+  },
+  -- comments
+  {
+    "numToStr/Comment.nvim",
+    opts = {
+      toggler = {
+        line = "gcc",
+        block = "gbb",
+      },
+      mappings = {
+        basic = true,
+        extra = true,
+      },
+    },
   },
+  { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false },
+  { "echasnovski/mini.comment", enabled = false },
 }