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 ---@param opts cmp.ConfigSchema
28 opts = function(_, opts)
29 local has_words_before = function()
30 unpack = unpack or table.unpack
31 local line, col = unpack(vim.api.nvim_win_get_cursor(0))
32 return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
35 local cmp = require("cmp")
36 local luasnip = require("luasnip")
38 local upstream_format = opts.formatting.format
39 opts.formatting.format = function(entry, vim_item)
40 vim_item = upstream_format(entry, vim_item)
47 vim_item.menu = menu[entry.source.name]
51 opts.completion = vim.tbl_extend("force", opts.completion, {
52 completeopt = "menu,menuone,noselect",
54 -- TODO: review if I want to keep any of LazyVim's mappings
55 opts.mapping = cmp.mapping.preset.insert({
57 ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
58 ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
59 ["<C-b>"] = cmp.mapping.scroll_docs(-4),
60 ["<C-f>"] = cmp.mapping.scroll_docs(4),
61 ["<C-e>"] = cmp.mapping.abort(),
62 ["<C-Space>"] = cmp.mapping.complete(),
64 ["<Tab>"] = cmp.mapping(function(fallback)
66 cmp.select_next_item()
67 elseif luasnip.expand_or_jumpable() then
68 luasnip.expand_or_jump()
69 elseif has_words_before() then
75 ["<S-Tab>"] = cmp.mapping(function(fallback)
77 cmp.select_prev_item()
78 elseif luasnip.jumpable(-1) then
90 "echasnovski/mini.pairs",
95 "echasnovski/mini.surround",
97 -- HACK: use function to disable merging with LazyVim's keys definition
99 { "ys", desc = "Add surrounding", "n" },
100 { "S", desc = "Add surrounding", "x" },
101 { "ds", desc = "Delete surrounding" },
102 { "cs", desc = "Change surrounding" },
103 { "yss", "ys_", remap = true },
108 -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings
109 -- see: :h MiniSurround-vim-surround-config
119 config = function(_, opts)
120 require("mini.surround").setup(opts)
122 vim.keymap.del("x", "ys", { silent = true })
123 vim.keymap.set("x", "S", [[:<C-u>lua MiniSurround.add('visual')<CR>]], { silent = true })
128 "numToStr/Comment.nvim",
140 { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false },
141 { "echasnovski/mini.comment", enabled = false },