local M = {} --- Setup and configure nvim-cmp -- This function initializes and configures the completion plugin -- @return boolean True if setup was successful, false otherwise function M.setup() -- Check Neovim version local nvim_version = vim.version() if nvim_version.major == 0 and nvim_version.minor < 5 then return false end -- Try to load required modules local cmp = pcall(require, 'cmp') and require('cmp') if not cmp then return false end local luasnip_ok, luasnip = pcall(require, 'luasnip') if not luasnip_ok then vim.notify("luasnip not found, some features may be limited", vim.log.levels.WARN) end -- Setup nvim-cmp cmp.setup({ snippet = { expand = function(args) if luasnip_ok then luasnip.lsp_expand(args.body) end end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm({ select = true }), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'buffer' }, }), }) vim.cmd([[ highlight! link CmpItemMenu Comment " gray highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080 " blue highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6 highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6 " light blue highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE " pink highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0 highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0 " front highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4 highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4 highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4 ]]) return true end return M