return { 'hrsh7th/nvim-cmp', event = 'InsertEnter', dependencies = { -- Snippet Engine & its associated nvim-cmp source { 'L3MON4D3/LuaSnip', build = (function() if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end return 'make install_jsregexp' end)(), }, 'saadparwaiz1/cmp_luasnip', -- Adds LSP completion capabilities 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', -- Adds a number of user-friendly snippets 'rafamadriz/friendly-snippets', }, config = function() -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' require('luasnip.loaders.from_vscode').lazy_load() require('luasnip.loaders.from_lua').lazy_load({ paths = '~/.config/nvim/snippets' }) luasnip.config.setup {} luasnip.filetype_extend('templ', { "html" }) cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, -- completion = { autocomplete = false }, completion = { completeopt = 'menu,menuone,noinsert' }, -- See `:help ins-completion` mapping = cmp.mapping.preset.insert { -- [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.confirm { select = true }, [''] = cmp.mapping.complete {}, -- 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' }, }, } cmp.setup.filetype('sql', { sources = { { name = 'vim-dadbod-completion' }, { name = 'buffer' }, }, }) end, }