我正在尝试从 vscode 切换到 neovim。我已为
coc.nvim
配置了 pyright
,但现在 neovim
为 language-server
提供本机支持。所以我尝试配置python-language-server
。我已经通过pyls
安装了pip 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)
我尝试用谷歌搜索但没有找到任何相关答案。如果您已配置,请帮我。
嘿,看来有一个新的 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]'
然后在
init.vim
更改:
lua require('lspconfig').pyls.setup{}
到
lua require('lspconfig').pylsp.setup{}
注意:pyls 更改为 pylsp
或者您可以在 Linux 中使用包管理器安装所有包,例如:
sudo apt-get install 'python3-pylsp*'
注意 * 这将安装所有 pylsp 软件包。