-- REQUIRED PLUGINS (via your plugin manager, e.g., Packer/Lazy): -- 1. 'hrsh7th/nvim-cmp' (The completion engine) -- 2. 'hrsh7th/cmp-nvim-lsp' (Bridge between LSP and cmp) -- 3. 'neovim/nvim-lspconfig' (Configs for ZLS) -- 4. 'L3MON4D3/LuaSnip' (Snippet engine, required by cmp) local cmp = require('cmp') local lspconfig = require('lspconfig') local luasnip = require('luasnip') -- 1. SETUP THE COMPLETION ENGINE cmp.setup({ -- Snippet expansion is required for arguments to populate correctly snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, -- Window styling for the suggestion box and documentation float window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, -- Key mappings mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), -- Force trigger completion [''] = cmp.mapping.confirm({ select = true }), -- Accept suggestion }), -- Sources: 'nvim_lsp' is what provides the intelligent 'self' data sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'buffer' }, }), -- formatting: This adds the "Method", "Field", "Text" icons formatting = { format = function(entry, vim_item) vim_item.menu = ({ nvim_lsp = "[LSP]", luasnip = "[Snippet]", buffer = "[Buffer]", })[entry.source.name] return vim_item end }, }) -- 2. SETUP ZIG LANGUAGE SERVER (ZLS) -- This captures the capabilities of nvim-cmp to send to ZLS local capabilities = require('cmp_nvim_lsp').default_capabilities() lspconfig.zls.setup({ capabilities = capabilities, -- ZLS Specific Settings to ensure you get arguments and details settings = { zls = { enable_snippets = true, -- Auto-fill arguments enable_argument_placeholders = true, -- Placeholders like (a: i32, b: bool) highlight_global_var_declarations = true, operator_completions = true, include_at_in_builtins = true, -- Suggest @import, @cImport }, }, })