return { { "hrsh7th/nvim-cmp", event = "VeryLazy", dependencies = { -- sources { "hrsh7th/cmp-nvim-lsp" }, { "hrsh7th/cmp-nvim-lua" }, { "hrsh7th/cmp-buffer" }, { "hrsh7th/cmp-path" }, { "hrsh7th/cmp-nvim-lsp-document-symbol" }, -- snippets { "L3MON4D3/LuaSnip" }, { "saadparwaiz1/cmp_luasnip" }, { "rafamadriz/friendly-snippets" }, -- lsp diagnostics { "hrsh7th/cmp-nvim-lsp-signature-help" }, { "onsails/lspkind.nvim" }, }, config = function() local cmp = require("cmp") local lspkind = require("lspkind") local luasnip = require("luasnip") cmp.setup({ snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) -- Luasnip expand end, }, window = { completion = { border = "rounded" }, documentation = { border = "rounded" }, }, mapping = { [""] = 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" }), ["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 = "nvim_lsp_signature_help" }, { name = "nvim_lsp_document_symbol" }, { name = "nvim_lua" }, { name = "luasnip" }, }, { { name = "buffer" }, { name = "path" }, }), formatting = { format = lspkind.cmp_format({ mode = "symbol_text", maxwidth = function() return math.floor(0.5 * vim.o.columns) end, ellipsis_char = "...", show_labelDetails = true, before = function(_, vim_item) return vim_item end, }), }, }) -- Add snippets from Friendly Snippets require("luasnip/loaders/from_vscode").lazy_load() end, }, }