return { -- TODO: Figureout how to add custom snippets { -- Autocompletion "hrsh7th/nvim-cmp", event = "InsertEnter", cond = require("config.util").is_not_vscode(), dependencies = { -- Snippet Engine & its associated nvim-cmp source { "L3MON4D3/LuaSnip", build = (function() -- Build Step is needed for regex support in snippets. -- This step is not supported in many windows environments. -- Remove the below condition to re-enable on windows. if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end return 'make install_jsregexp' end)(), dependencies = { -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets { "rafamadriz/friendly-snippets", config = function() require('luasnip.loaders.from_vscode') end, }, }, }, "saadparwaiz1/cmp_luasnip", -- Adds LSP completion capabilities "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", "hrsh7th/cmp-vsnip", "hrsh7th/vim-vsnip", }, config = function() -- See `:help cmp` local cmp = require("cmp") local defaults = require("cmp.config.default")() local luasnip = require("luasnip") require("luasnip.loaders.from_vscode").lazy_load() luasnip.config.setup({}) -- vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) cmp.setup({ -- experimental = { -- ghost_text = { -- hl_group = "CmpGhostText", -- }, -- }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, completion = { completeopt = "menu,menuone,noinsert", }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete({}), [""] = cmp.mapping.abort(), -- Enter to perform the completion [""] = cmp.mapping.confirm({ select = true, }), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, }), -- will move you to the right of each of the expansion locations -- is similar, except moving you backwards. [""] = cmp.mapping(function() if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end end, { 'i', 's' }), [""] = cmp.mapping(function() if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end end, { 'i', 's' }), }), sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" }, { { name = "buffer" } }, }, sorting = defaults.sorting, }) end, }, { "L3MON4D3/LuaSnip", cond = require("config.util").is_not_vscode(), keys = { { "", function() return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" end, expr = true, silent = true, mode = "i", }, { "", function() require("luasnip").jump(1) end, mode = "s", }, { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" }, }, }, }, }