2

I am using a nightly build of nvim, and I am trying to use neovim/nvim-lspconfig. I have followed to doc and setup the language server, but nvim throws error and reports that it is unable to process it.

The error is coming from the lua part. When I comment out it everything works as normal. Here is my code:

Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'

:lua << EOF
    require'lspconfig'.tsserver.setup{}
EOF

What have I done wrong? I have checked the doc again but I cannot find the error.

Update

This is the error message. Why is lspconfig not found? I have already :PlugInstalled.

E5108: Error executing lua [string ":lua"]:1: module 'lspconfig' not found:
        no field package.preload['lspconfig']
        no file './lspconfig.lua'
        no file '/usr/local/Cellar/luajit-openresty/20201229_1/share/luajit-2.1.0-beta3/lspconfig.lua'

        no file '/usr/local/share/lua/5.1/lspconfig.lua'
        no file '/usr/local/share/lua/5.1/lspconfig/init.lua'
        no file '/usr/local/Cellar/luajit-openresty/20201229_1/share/lua/5.1/lspconfig.lua'
        no file '/usr/local/Cellar/luajit-openresty/20201229_1/share/lua/5.1/lspconfig/init.lua'
        no file './lspconfig.so'
        no file '/usr/local/lib/lua/5.1/lspconfig.so'
        no file '/usr/local/Cellar/luajit-openresty/20201229_1/lib/lua/5.1/lspconfig.so'

2 Answers 2

2

In order to load the plugins, you have to wrap your Plug part with call plug#begin(<path>) and call plug#end(). So it should look like this for example:

call plug#begin('~/.vim/plugged')
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
call plug#end()

lua require('lspconfig').tsserver.setup{}
2
  • This answer fixed it for me!
    – Krish
    Aug 18, 2021 at 15:12
  • Glad to hear this :)
    – TornaxO7
    Sep 25, 2021 at 22:26
1

The issue was fixed for me by ensuring lua << EOF and EOF were at the very beginning of their line. If there is even a tab or one space it breaks for me.

Your Answer

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

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