return { {{- if eq .chezmoi.os "openbsd" }} -- 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", { "garymjr/nvim-snippets", opts = { friendly_snippets = true, }, dependencies = { "rafamadriz/friendly-snippets" }, }, }, opts = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local kind_icons = { Text = " ", Method = " ", Function = " ", Constructor = " ", Field = " ", Variable = " ", Class = " ", Interface = " ", Module = " ", Property = " ", Unit = "", Value = " ", Enum = " ", Keyword = " ", Snippet = " ", Color = " ", File = " ", Reference = " ", Folder = " ", EnumMember = " ", Constant = " ", Struct = " ", Event = " ", Operator = " ", TypeParameter = "󰅲", } local cmp = require("cmp") local defaults = require("cmp.config.default")() return { completion = { completeopt = "menu,menuone,noinsert", }, snippet = { expand = function(args) vim.snippet.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 = "snippets" }, { name = "path" }, }, { { name = "buffer", keyword_length = 3 }, }), formatting = { format = function(entry, vim_item) -- Kind icons vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatenates the icons with the name of the item kind -- Source vim_item.menu = ({ buffer = "[Buffer]", nvim_lsp = "[LSP]", snippets = "[Snippets]", nvim_lua = "[Lua]", latex_symbols = "[LaTeX]", })[entry.source.name] return vim_item end }, experimental = { ghost_text = { hl_group = "CmpGhostText", }, }, sorting = defaults.sorting, } end, keys = { { "", function() return vim.snippet.active({ direction = 1 }) and "lua vim.snippet.jump(1)" or "" end, expr = true, silent = true, mode = { "i", "s" }, }, { "", function() return vim.snippet.active({ direction = -1 }) and "lua vim.snippet.jump(-1)" or "" end, expr = true, silent = true, mode = { "i", "s" }, }, }, config = function(_, opts) for _, source in ipairs(opts.sources) do source.group_index = source.group_index or 1 end require("cmp").setup(opts) end, }, { "kylechui/nvim-surround", version = "*", -- Use for stability; omit to use `main` branch for the latest features event = "VeryLazy", config = function() require("nvim-surround").setup({ -- Configuration here, or leave empty to use defaults }) end }, {{ end }} { "windwp/nvim-autopairs", event = "InsertEnter", opts = { fast_wrap = {}, }, }, }