return { { "hrsh7th/cmp-nvim-lsp" }, { "L3MON4D3/LuaSnip", -- follow latest release. version = "v2.*", -- Replace by the latest released major (first number of latest release) -- install jsregexp (optional!). build = "make install_jsregexp", dependencies = { "saadparwaiz1/cmp_luasnip", "rafamadriz/friendly-snippets" }, }, { "hrsh7th/nvim-cmp", dependencies = { "hrsh7th/cmp-buffer", "f3fora/cmp-spell", "hrsh7th/cmp-path", "hrsh7th/cmp-emoji", "R-nvim/cmp-r", "hrsh7th/cmp-nvim-lsp-signature-help" }, config = function() local cmp = require("cmp") local luasnip = require("luasnip") require("luasnip.loaders.from_vscode").lazy_load() cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. require("luasnip").lsp_expand(args.body) -- For `luasnip` users. -- require('snippy').expand_snippet(args.body) -- For `snippy` users. -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) end, }, window = { -- completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping(function(fallback) if cmp.visible() then if luasnip.expandable() then luasnip.expand() else cmp.confirm({ select = true, }) end else fallback() end end), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.locally_jumpable(1) then luasnip.jump(1) else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.locally_jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "buffer" }, { name = "luasnip" }, -- For luasnip users. { name = 'emoji' }, { name = "crates" }, -- cf rust { name = 'cmp_r' }, { name = 'nvim_lsp_signature_help' }, { name = "spell", option = { keep_all_entries = false, enable_in_context = function() return true end, preselect_correct_word = true, }, }, { name = "path", option = { -- Options go into this table }, }, -- { name = 'ultisnips' }, -- For ultisnips users. -- { name = 'snippy' }, -- For snippy users. }, { { name = "buffer" }, }), }) -- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below -- Set configuration for specific filetype. --[[ cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'git' }, }, { { name = 'buffer' }, }) }) require("cmp_git").setup() ]] -- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline({ "/", "?" }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = "buffer" }, }, }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- cmp.setup.cmdline(":", { -- mapping = cmp.mapping.preset.cmdline(), -- sources = cmp.config.sources({ -- { name = "path" }, -- }, { -- { name = "cmdline" }, -- }), -- matching = { disallow_symbol_nonprefix_matching = false }, -- }) end, }, }