VonHeikemen / lsp-zero.nvim

A starting point to setup some lsp related features in neovim.
https://lsp-zero.netlify.app/v4.x/
MIT License
3.75k stars 95 forks source link

cmp not active #280

Closed Rydwxz closed 1 year ago

Rydwxz commented 1 year ago

I followed the installation steps but I'm not getting any completion. init.lua -

local lsp = require('lsp-zero').preset({})

lsp.on_attach(function(client, bufnr)
  lsp.default_keymaps({buffer = bufnr})
end)

lsp.setup()

local cmp = require('cmp')
local cmp_sel_opt = {behavior = cmp.SelectBehavior.Select}
cmp.setup({
    sources = {
        { name = 'path' },
        { name = 'nvim-lsp'},
        { name = 'buffer' },
    },
    mapping = {
        ['<CR>'] = cmp.mapping.confirm({select = true}),
        ['<Esc>'] = cmp.mapping.abort(),
        ['<Tab>'] = cmp.mapping.select_next_item(cmp_sel_opt),
        ['<Left>'] = cmp.mapping.select_prev_item(cmp_sel_opt),
        ['<Down>'] = cmp.mapping.scroll_docs(4),
    }
})

lazy spec -

return {

    "VonHeikemen/lsp-zero.nvim",
    dependencies = {
        {
            'neovim/nvim-lspconfig'},
        {
            'williamboman/mason.nvim',
            build = function()
                pcall(vim.cmd, 'MasonUpdate')
            end,
        },
        {'williamboman/mason-lspconfig.nvim'},

        {'hrsh7th/nvim-cmp'},     -- Required
      {'hrsh7th/cmp-nvim-lsp'}, -- Required
      {'L3MON4D3/LuaSnip'},     -- Required
    }

}
VonHeikemen commented 1 year ago

Each source that you include in nvim-cmp is neovim plugin you need to install.

The source for the LSP completions depends on the active language servers. What language servers are you using?

Rydwxz commented 1 year ago

TY very much for explaining that to me, I successfully installed a bunch of LSPs I simply missed those two installations co cmp was online but doing nothing. The docs are clear but my mind is not. I put them in front of lsp-zero in my lazy spec and it's 100% working as far as I can tell.