neovimpython-language-server

Trying to Configure pyls through nvim-lspconfig


I'm trying to switch from vscode to neovim. I have coc.nvim configured for pyright but now neovim provides native support for language-server. So I tried to configure python-language-server. I have installed pyls by pip install python-language-server. I went through the documentation for lsp-quickstart. It says that I just need to add neovim/nvim-lspconfig to my plugins and then add lua require('lspconfig').pyls.setup{} to my init.vim. After refreshing I'm getting Error:

E5108: Error executing lua [string ":lua"]:1: attempt to index field 'pyls' (a nil value)

I tried googling it but didn't find any relevant answer. Please help me out if you've configured it.


Solution

  • Hey so it looks like there is a new fork of pyls. I had the same issue and the following worked for me!

    See Here:

    https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#pylsp

    And Here:

    https://github.com/python-lsp/python-lsp-server

    Try:

    pip install 'python-lsp-server[all]'
    

    Then in init.vim change:

    lua require('lspconfig').pyls.setup{}
    

    to

    lua require('lspconfig').pylsp.setup{}
    

    Note: pyls changes to pylsp