return { {{- if eq .chezmoi.os "openbsd" }} -- snippets { "L3MON4D3/LuaSnip", build = (not jit.os:find("Windows")) and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp" or nil, dependencies = { "rafamadriz/friendly-snippets", config = function() require("luasnip.loaders.from_vscode").lazy_load() end, }, opts = { history = true, delete_check_events = "TextChanged", }, -- stylua: ignore 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" } }, }, }, -- auto completion { "hrsh7th/nvim-cmp", version = false, -- last release is way too old event = "InsertEnter", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "saadparwaiz1/cmp_luasnip", }, opts = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local luasnip = require('luasnip') local lspkind = require('lspkind') local cmp = require("cmp") local defaults = require("cmp.config.default")() return { completion = { completeopt = "menu,menuone,noinsert", }, snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. [""] = function(fallback) cmp.abort() fallback() end, }), sources = cmp.config.sources({ { name = "nvim_lsp", keyword_length = 1 }, { name = "luasnip", keyword_length = 2 }, { name = "path" }, }, { { name = "buffer", keyword_length = 3 }, }), formatting = { format = lspkind.cmp_format({ mode = 'symbol_text', -- show only symbol annotations maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) }) }, experimental = { ghost_text = { hl_group = "CmpGhostText", }, }, sorting = defaults.sorting, } end, config = function(_, opts) for _, source in ipairs(opts.sources) do source.group_index = source.group_index or 1 end require("cmp").setup(opts) end, }, {{ else }} { "hrsh7th/nvim-cmp", opts = function(_, opts) local cmp = require("cmp") opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "neorg" } })) end, }, {{ end }} { "windwp/nvim-autopairs", event = "InsertEnter", opts = { fast_wrap = {}, }, }, }