1 ---@type LazyPluginSpec
6 -- disable luasnip bindings for <tab> and <s-tab>
11 require("luasnip.loaders.from_snipmate").lazy_load()
12 require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath("config") .. "/lua/snippets" })
20 store_selection_keys = "<Tab>",
27 version = false, -- last release is way too old
28 event = "InsertEnter",
30 "hrsh7th/cmp-nvim-lsp",
33 "saadparwaiz1/cmp_luasnip",
35 ---@param opts cmp.ConfigSchema
36 opts = function(_, opts)
37 local has_words_before = function()
38 unpack = unpack or table.unpack
39 local line, col = unpack(vim.api.nvim_win_get_cursor(0))
40 return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
43 local cmp = require("cmp")
44 local luasnip = require("luasnip")
46 local upstream_format = opts.formatting.format
47 opts.formatting.format = function(entry, vim_item)
48 vim_item = upstream_format(entry, vim_item)
55 vim_item.menu = menu[entry.source.name]
59 opts.completion = vim.tbl_extend("force", opts.completion, {
60 completeopt = "menu,menuone,noselect",
62 -- TODO: review if I want to keep any of LazyVim's mappings
63 opts.mapping = cmp.mapping.preset.insert({
65 ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
66 ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
67 ["<C-b>"] = cmp.mapping.scroll_docs(-4),
68 ["<C-f>"] = cmp.mapping.scroll_docs(4),
69 ["<C-e>"] = cmp.mapping.abort(),
70 ["<C-Space>"] = cmp.mapping.complete(),
72 ["<Tab>"] = cmp.mapping(function(fallback)
74 cmp.select_next_item()
75 elseif luasnip.expand_or_jumpable() then
76 luasnip.expand_or_jump()
77 elseif has_words_before() then
83 ["<S-Tab>"] = cmp.mapping(function(fallback)
85 cmp.select_prev_item()
86 elseif luasnip.jumpable(-1) then
98 "echasnovski/mini.pairs",
103 "echasnovski/mini.surround",
105 -- HACK: use function to disable merging with LazyVim's keys definition
107 { "ys", desc = "Add surrounding", "n" },
108 { "S", desc = "Add surrounding", "x" },
109 { "ds", desc = "Delete surrounding" },
110 { "cs", desc = "Change surrounding" },
111 { "yss", "ys_", remap = true },
116 -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings
117 -- see: :h MiniSurround-vim-surround-config
127 config = function(_, opts)
128 require("mini.surround").setup(opts)
130 vim.keymap.del("x", "ys", { silent = true })
131 vim.keymap.set("x", "S", [[:<C-u>lua MiniSurround.add('visual')<CR>]], { silent = true })
136 "numToStr/Comment.nvim",
148 { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false },
149 { "echasnovski/mini.comment", enabled = false },