1 ---@type LazyPluginSpec
6 -- disable luasnip bindings for <tab> and <s-tab>
11 require("luasnip.loaders.from_snipmate").lazy_load()
19 store_selection_keys = "<Tab>",
26 ---@param opts cmp.ConfigSchema
27 opts = function(_, opts)
28 local has_words_before = function()
29 unpack = unpack or table.unpack
30 local line, col = unpack(vim.api.nvim_win_get_cursor(0))
31 return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
34 local cmp = require("cmp")
35 local luasnip = require("luasnip")
37 local upstream_format = opts.formatting.format
38 opts.formatting.format = function(entry, vim_item)
39 vim_item = upstream_format(entry, vim_item)
46 vim_item.menu = menu[entry.source.name]
50 opts.completion = vim.tbl_extend("force", opts.completion, {
51 completeopt = "menu,menuone,noselect",
53 -- TODO: review if I want to keep any of LazyVim's mappings
54 opts.mapping = cmp.mapping.preset.insert({
56 ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
57 ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
58 ["<C-b>"] = cmp.mapping.scroll_docs(-4),
59 ["<C-f>"] = cmp.mapping.scroll_docs(4),
60 ["<C-e>"] = cmp.mapping.abort(),
61 ["<C-Space>"] = cmp.mapping.complete(),
63 ["<Tab>"] = cmp.mapping(function(fallback)
65 cmp.select_next_item()
66 elseif luasnip.expand_or_jumpable() then
67 luasnip.expand_or_jump()
68 elseif has_words_before() then
74 ["<S-Tab>"] = cmp.mapping(function(fallback)
76 cmp.select_prev_item()
77 elseif luasnip.jumpable(-1) then
89 "echasnovski/mini.pairs",
94 "echasnovski/mini.surround",
96 { "S", "<cmd><C-u>lua MiniSurround.add('visual')<cr>", "x" },
97 { "yss", "ys_", remap = true },
101 -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings
102 -- see: :h MiniSurround-vim-surround-config
115 "numToStr/Comment.nvim",
127 { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false },
128 { "echasnovski/mini.comment", enabled = false },