尝试通过 nvim-lspconfig 配置 pyls

Dhr*_*ana 4 neovim python-language-server

我正在尝试从vscode切换到neovim。我已经coc.nvim配置了,pyright但现在neovim提供了对language-server. 所以我尝试配置python-language-server。我已经安装pylspip install python-language-server。我浏览了 的文档lsp-quickstart。它说我只需要添加 neovim/nvim-lspconfig到我的插件,然后添加lua require('lspconfig').pyls.setup{}到我的init.vim. 刷新后出现错误:

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

我尝试用谷歌搜索但没有找到任何相关答案。如果你配置好了的话请帮帮我。

小智 9

嘿,看来有一个新的 pyls 分支。我遇到了同样的问题,以下内容对我有用!

看这里:

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

和这里:

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

尝试:

pip install 'python-lsp-server[all]'
Run Code Online (Sandbox Code Playgroud)

然后在init.vim变化中:

lua require('lspconfig').pyls.setup{}
Run Code Online (Sandbox Code Playgroud)

lua require('lspconfig').pylsp.setup{}
Run Code Online (Sandbox Code Playgroud)

注意:pyls 更改为 pylsp