hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.86k stars 393 forks source link

cmp don't work even my config are seem to be correct #1929

Open ryannewcomer opened 4 months ago

ryannewcomer commented 4 months ago

FAQ

Announcement

Minimal reproducible full config

return {
    'hrsh7th/nvim-cmp',
    dependencies = {'L3MON4D3/LuaSnip', 'neovim/nvim-lspconfig', 'hrsh7th/cmp-nvim-lsp'},
    config = function ()
        local luasnip = require("luasnip")
        local cmp = require("cmp")

        cmp.setup({
            snippet = {
                expand = function(args)
                    require('luasnip').lsp_expand(args.body)
                end,
            },
            mapping = {
                ['<CR>'] = cmp.mapping(function(fallback)
                    if cmp.visible() then
                        if luasnip.expandable() then
                            luasnip.expand()
                        else
                            cmp.confirm({
                                select = true,
                            })
                        end
                    else
                        fallback()
                    end
                end),
                ["<Tab>"] = cmp.mapping(function(fallback)
                    if cmp.visible() then
                        cmp.select_next_item()
                    elseif luasnip.locally_jumpable(1) then
                        luasnip.jump(1)
                    else
                        fallback()
                    end
                end, { "i", "s" }),
                ["<S-Tab>"] = cmp.mapping(function(fallback)
                    if cmp.visible() then
                        cmp.select_prev_item()
                    elseif luasnip.locally_jumpable(-1) then
                        luasnip.jump(-1)
                    else
                        fallback()
                    end
                end, { "i", "s" }),
            },
        })
        sources = cmp.config.sources({
            { name = 'nvim_lsp' },
            { name = 'luasnip' }, -- For luasnip users.
        }, {
            { name = 'buffer' },
        })
        local capabilities = require('cmp_nvim_lsp').default_capabilities()
        require('lspconfig')['lua_ls'].setup {
            capabilities = capabilities
        }
    end
}

Description

I have successfully installed lua ls in my lspconfig, I have checked LspInfo and it side that the Lua language server is working and has autostart, in my cmp config, I just changed the keymap to a 'super tab' like. the lsp is working as I can see the error and warning. but as I type, the auto-completion doesn't show up.

:LspInfo image

Steps to reproduce

install lspconfig, config it to:

return {
    'neovim/nvim-lspconfig',
   config = function ()
        require'lspconfig'.lua_ls.setup{}
        require'lspconfig'.pylsp.setup{}
    end
}

install luasnip, config it:

return {
    'L3MON4D3/LuaSnip',
  dependencies = { "rafamadriz/friendly-snippets" },
    version = 'v2.*',
  build = "make install_jsregexp",
  config = function ()
    require("luasnip.loaders.from_vscode").lazy_load()
  end
}

install cmp, config it.

restart nvim, the plugin is cloned, but auto-completion don't work

Expected behavior

it should show up (the auto-completion)

Actual behavior

https://github.com/hrsh7th/nvim-cmp/assets/88273136/2b42ff63-df0a-426c-af43-31ff9f2bd26f

as you can see, the color scheme work, treesitter work, but not auto complete

Additional context

O.S

windows 11 23H2

nvim version: image

my full config: https://github.com/ryannewcomer/nvim-windows

longway1024 commented 3 months ago

https://github.com/hrsh7th/nvim-cmp/issues/1692#issuecomment-1700555900 for your information

erlangparasu commented 3 months ago

Got same issue. cmp completion ( via <C-Space> ) not working on macOS

Related issue from other site: https://www.reddit.com/r/neovim/comments/19372gt/lazyvim_cmp_not_opening_on_key/