0

I'm getting:

Error detected while processing /Users/dstromberg/.vim/init.lua:
E5113: Error while calling lua chunk: ...cker/start/lsp-zero.nvim/lua/lsp-zero/nvim-cmp-setup.lua:12: attempt to index field 'SelectBehavior' (a nil value)
stack traceback:
        ...cker/start/lsp-zero.nvim/lua/lsp-zero/nvim-cmp-setup.lua:12: in main chunk
        [C]: in function 'require'
        ...im/site/pack/packer/start/lsp-zero.nvim/lua/lsp-zero.lua:32: in function 'setup'
        /Users/dstromberg/.vim/init.lua:35: in main chunk
Press ENTER or type command to continue

...with the following ~/.vim/init.lua:

-- vim.opt.tabstop = 4
-- vim.opt.shiftwidth = 4
-- vim.opt.softtabstop = 4
-- vim.opt.expandtab = true

require('packer').startup(function(use)
    use {
        -- packer can manage itself
        'wbthomason/packer.nvim',
        'VonHeikemen/lsp-zero.nvim',
        requires = {
            -- LSP Support
            {'neovim/nvim-lspconfig'},
            {'williamboman/mason.nvim'},
            {'williamboman/mason-lspconfig.nvim'},

            -- Autocompletion
            {'hrsh7th/nvim-cmp'},
            {'hrsh7th/cmp-buffer'},
            {'hrsh7th/cmp-path'},
            {'saadparwaiz1/cmp_luasnip'},
            {'hrsh7th/cmp-nvim-lsp'},
            {'hrsh7th/cmp-nvim-lua'},

            -- Snippets
            {'L3MON4D3/LuaSnip'},
            {'rafamadriz/friendly-snippets'},
        }
    }
end)

local lsp = require('lsp-zero')

lsp.preset('recommended')
lsp.setup()

I'm just getting started with Neovim; this hasn't worked for me previously.

I'm using:

$ nvim --version
cmd output started 2022 Wed Dec 28 01:08:28 PM PST
NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.1/share/nvim"

Run :checkhealth for more info

On an Intel Mac:

$ sw_vers 
cmd output started 2022 Wed Dec 28 01:09:39 PM PST
ProductName:    macOS
ProductVersion: 12.6
BuildVersion:   21G115

Also, I'm using today's packer 'master' branch. :PackerSync inside Neovim says Everything already up to date!

My ultimate goal is to get LSP working with Python and bash, and probably others as needed. I really like the sound of Mason taking care of that for me - if/when it works.

Any suggestions? I've googled for hours, but didn't find much other than people saying "It just works".

2 Answers 2

1

This happened because the module for nvim-cmp was not loaded properly. Make sure nvim-cmp is installed and is accesible. You can execute the command :lua require('cmp') and if that throws an error it means something went wrong during the installation of nvim-cmp.

0

For me, it happened because I just recently updated my plugins (including nvim-cmp). They changed the parameters that went into cmp.select_prev_item() and cmp.select_next_item() ...or maybe I mistyped them?

I suggest you type :help cmp and search by typing /select_ to check out the different usages and parameters allowed.

PS: if you have just updated your plugins, restart your Neovim to load up the updated docs... very important.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.