Open arusahni opened 4 years ago
From the link, Pylance is based on Pyright, maybe you can try this: https://github.com/fannheyward/coc-pyright
After a quick glance, Pylance = Pyright + onnxruntime based AI + LSP.
But the LICENSE says
a) General. You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications.
So it's not legit to use it outside of MS products?
Can we replace https://github.com/Microsoft/python-language-server with https://github.com/Microsoft/pyright?
Can we replace https://github.com/Microsoft/python-language-server with https://github.com/Microsoft/pyright?
Pyright is only a type checker, not a fully-featured LSP.
Can we replace Microsoft/python-language-server with Microsoft/pyright?
Pyright is only a type checker, not a fully-featured LSP.
No. It has LSP features like jump to definition and code completion. It has generally much better experience than MPLS. Microsoft recommends pylanche which uses pyright under the hood now.
so.. how do we do to enable this exactly?
I just tried to get it work, here is my coc-settings:
"pylance": {
"enable": true,
"filetypes": ["python"],
// absolute path to server.bundle.js
"module": "~/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/server.bundle.js",
"initializationOptions": {},
"settings": {
"python.analysis.typeCheckingMode": "basic",
"python.analysis.diagnosticMode": "openFilesOnly",
"python.analysis.stubPath": "./typings",
"python.analysis.autoSearchPaths": true,
"python.analysis.extraPaths": [],
"python.analysis.diagnosticSeverityOverrides": {},
"python.analysis.useLibraryCodeForTypes": true
}
},
The configuration options can be found here.
@sainnhe I'm assuming this is under the languageserver
section of coc-settings? If so, having installed the plugin in VS Code, I'm getting the following error with your snippet:
[coc.nvim] Module file "~/.vscode/extensions/ms-python.vscode-pylance-2020.7.3/server/server.bundle.js" not found for LS "pylance"
Any tips on debugging this? I've confirmed the file exists at that path, and have tried both the version of the path in your config, as well as an absolute path'd one.
Weird ... Shouldn't this all be downloaded from you by COC?
This config also works for me:
"pylance": {
"enable": true,
"filetypes": ["python"],
"command": "node",
"args": ["/home/sainnhe/.vscode-oss/extensions/ms-python.vscode-pylance-2020.7.3/server/server.bundle.js", "--stdio"],
"initializationOptions": {},
"settings": {
"python.analysis.typeCheckingMode": "basic",
"python.analysis.diagnosticMode": "openFilesOnly",
"python.analysis.stubPath": "./typings",
"python.analysis.autoSearchPaths": true,
"python.analysis.extraPaths": [],
"python.analysis.diagnosticSeverityOverrides": {},
"python.analysis.useLibraryCodeForTypes": true
}
You can try this command in your terminal:
$ node ~/.vscode-oss/extensions/ms-python.vscode-pylance-2020.7.3/server/server.bundle.js --stdio
Content-Length: 139
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pylance language server 2020.7.3 (pyright 5004efe5) starting"}}Content-Length: 179
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /home/sainnhe/.vscode-oss/extensions/ms-python.vscode-pylance-2020.7.3/server"}}
Btw, I think the preferred solution should be using pyright.
Pyright is an open source python language server maintained by microsoft python team, they distributed the source code under MIT license.
Pylance adds the IntelliCode component on the basis of pyright. IntelliCode seems to be maintained by another team and is distributed under a very strict license, and this is why the python team said it's hard to make pylance open source.
I'm considering switching back to pyright since it's a FOSS.
Any update? Maybe coc-python and coc-pyright can merge into one repo by discarding MPLS
@sainnhe Does your setup still work for you with the October release of PyLance? I used your approach and pylance was working, but my configuration was not being read. I looked at the logs and saw that coc was correctly sending a workspace/didChangeConfiguration
with everything under settings
, but PyLance didn't seem to register the settings.
I had to place the settings fields under the top level. Then they are sent to Pylance when Pylance requests them via workspace/configuration
.
@smackesey I'm using pyright though, but I noticed that there are 2 new configuration options in the latest release of pylance (python.analysis.autoImportCompletions
and python.analysis.completeFunctionParens
), see https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance
Maybe you can add them in your coc settings and try again.
Microsoft just announced their new Python LSP that includes their typechecker. Given their plan is to deprecate their existing language server, will coc-python adjust accordingly?