---@module "lazy" ---@type LazySpec return { { "L3MON4D3/LuaSnip", dependencies = { "rafamadriz/friendly-snippets", }, config = function() local lua_snippets = vim.fn.stdpath("config") .. "/luasnip" local vscode_snippets = vim.fn.stdpath("config") .. "/snippets" local types = require("luasnip.util.types") require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load({ paths = { vscode_snippets } }) require("luasnip.loaders.from_lua").lazy_load({ paths = { lua_snippets } }) require("luasnip").config.setup({ ext_opts = { [types.choiceNode] = { active = { virt_text = {{"", "GruvboxOrange"}} } }, [types.insertNode] = { active = { virt_text = {{"", "GruvboxBlue"}} } } } }) end, lazy = true, }, { "windwp/nvim-autopairs", event = "InsertEnter", config = true, }, { "hrsh7th/nvim-cmp", event = { "InsertEnter" }, dependencies = { "LuaSnip", "hrsh7th/cmp-nvim-lsp", "onsails/lspkind.nvim", "saadparwaiz1/cmp_luasnip", "nvim-autopairs", "chrisgrieser/cmp-nerdfont", }, opts = function() vim.lsp.config("*", {capabilities = require("cmp_nvim_lsp").default_capabilities()}) local cmp = require("cmp") local luasnip = require("luasnip") local lspkind = require("lspkind") local cmp_autopairs = require("nvim-autopairs.completion.cmp") cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done() ) ---@type cmp.ConfigSchema return { enabled = function() local disabled = false disabled = disabled or (vim.api.nvim_get_option_value("buftype", { buf = 0 }) == "prompt") disabled = disabled or (vim.fn.reg_recording() ~= "") disabled = disabled or (vim.fn.reg_executing() ~= "") disabled = disabled or require("cmp.config.context").in_treesitter_capture("comment") return not disabled end, preselect = cmp.PreselectMode.None, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, window = { completion = { scrollbar = false, }, }, mapping = { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() else fallback() end end, { "i", "s" }), ["x"] = cmp.mapping(function (fallback) if luasnip.choice_active() then luasnip.change_choice(1) else fallback() end end), ["z"] = cmp.mapping(function (fallback) if luasnip.choice_active() then luasnip.change_choice(-1) else fallback() end end), [""] = 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" }), [""] = cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then cmp.confirm({ behaviour = cmp.ConfirmBehavior.Replace, select = false, }) else fallback() end end, s = cmp.mapping.confirm({ select = false }), c = cmp.mapping.confirm({ behaviour = cmp.ConfirmBehavior.Insert, select = false, }), }), [""] = cmp.mapping(function(_) cmp.complete() end), [""] = cmp.mapping(function (fallback) if cmp.visible() then cmp.close() else fallback() end end) }, sources = cmp.config.sources({ { name = "lazydev" }, { name = "nvim_lsp" }, { name = "luasnip" }, { name = "nerdfont" }, }), formatting = { format = lspkind.cmp_format({ mode = "symbol_text", menu = { nvim_lsp = "[LSP]", luasnip = "[SNP]", lazydev = "[LZY]", nerdfont = "[SYM]", }, maxwidth = 50, ellipsis_char = "", }), }, experimental = { ghost_text = true, }, } end, }, } -- vim: fdl=2