-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update example vscode extension #357
Conversation
This sounds awesome! Some well-needed refactors and some exciting new directions. So does that mean that in order to bootstrap VSCode-based language server we'll point to |
I'm hoping that our extension will be simple enough that is can remain a single Then point people to |
Ah right, yeah that sounds great. |
85d8327
to
b7b218c
Compare
This refactors the example server that was part of the `json-vscode-extension` into a single file that now lives in the `examples/servers` directory. Additionaly, relevant test cases that were part of the unit test suite for the json-server have been converted into end-to-end tests in the `tests/lsp/` directory. To support writing these and any new test cases going forward, there is a test language client in `tests/client.py` with support for "catching" messages like diagnostics from the server, as well as waiting for certain notifications coming from the server.
This refactor changes the purpose of the example VSCode extension from integrating a single language server into VSCode to providing a playground in which to experiment with the `pygls` framework in general. Now the extension will - Start the server when the user opens the first text file/notebook - Restart the server if - they change Python environment - change a setting that affects the client/server - trigger it manually via the command palette - save the text file containing the current server's source code Additionally, the following technology upgrades have been performed - Upgrading `vscode-languageclient-node` to `8.1.0` - adding support for the new `v3.17` LSP methods - Using `@vscode/python-extension` to grab the user's currently configured Python environment - rather than forcing them to configure it manually. - Using a `LogOutputChannel` for all client side logging
af9c62d
to
a5019e1
Compare
a5019e1
to
b2c1ee6
Compare
VSCode Extension Changes This PR changes the purpose of the example VSCode extension from integrating a single language server into VSCode to providing a playground in which to experiment with the There's still plenty that could be added, (see all TODOs left in The extension will now
The following config options have been introduced
Finally, the following technology upgrades have been performed
Supporting changes
|
This looks great! I'm still digesting it, I'll reply more soon once I've got the gist of what's here. |
I tried installing the playground myself, but got an error at the "Launch Client" step: Error
I'm not a VSCode user so I could be missing something really obvious. BTW, I also had to add the Python extension, which meant a restart of VSCode, I don't know if that's a step worth mentioning in the README? I don't think the screenshot from the comment above is in this PR? I think it, or something similar, would be good to add. And maybe a brief description of what can be done in the playground? I assume that the idea is that a sever (say the Also, seeing as VSCode works in the browser, is this something that we could put online!? |
Hmm, not much to go on... I assume the error log you shared is from the Debug Console in the VSCode instance you are running "Launch Client" from? Have you managed to find the
Good points, I'll update the README :)
Yes
We'd have to publish it in the VSCode Marketplace... but yes at least enabling VSCode + pygls in the browser has been a dream of mine since #218 While the now deleted Not that I think we need to get rid of pyodide! But I do have a proof of concept branch that enables WASI support for |
I got a bit further with that error. So the "Output" tab in the child VSCode instance has the debug from the I've tried activating the venv ( Oh wow, ok, so WASM-WASI is the path forward for in-browser Python. And you've already got a proof of concept, that's amazing. I see you've got some fancy Nix stuff going on 🤓 Does that mean you're just hacking on that locally (as in outside of any browser environment), the main difference that you use |
Strange... that should be the right command.... Time passes Ah, after trying it myself I think I know what your issue might be... when you run the It looks like you need to choose that first option, corresponding with the
in VSCode at least, pyodide would still make sense in other web contexts (like Jupyterlite maybe?)
Pretty much... though perhaps I misspoke when I said WASM-WASI was a runtime, it's actually a specification on what APIs a process running under WASI can expect to be available. wasmtime is one implementation that you can use to run If you're interested this blog post covers all this better than I can 😄
Haha, I've been playing with it over the last year or so, very nice when I can convince it to work! 😅 |
Version 1.6.0 dropped support for Python 3.7 https://github.com/python-poetry/poetry/releases/tag/1.6.0
That's strange... though just to confirm the expected behavior, once that second VSCode window is open, the language server should start once you open a file in the I've updated the README to include the screenshots in this thread and some notes about installing the Python extension and choosing the environment. I also had to pin the version of poetry in CI, since 3.7 support was dropped recently 🤞 this is ready to merge? 🙂 |
Oh I suspected that might be the case
Great
Great, thanks
Amdani! |
That's frustrating, the whole point of this change was to have things Just WorkTM 😅
I'm running Linux To ask some of the "obvious" questions
Assuming the above doesn't fix anything and that you're launching the extension via our Would you mind trying the following and seeing if the issue persists?
|
@z80dev I'm on Linux too
|
Awesome! So it sounds like, the extension is not handling the multi-root setup correctly... I wonder why it managed to work for me 🤔
That looks like a bug in the workspace_diagnostic method, not handling the case where the server's workspace is empty |
Ohh interesting, yeah multi-root isn't so common, so makes sense. So there's no need to support empty workspace in the example workspace right? Just good to know what's happening right? |
I think we're talking about different workspaces 😅. The error is the server failing to handle the case where the user has not yet opened any documents in the editor yet - thus pygls' internal Definitely one to fix, see my incoming PR :) |
Description (e.g. "Related to ...", etc.)
The example
json-vscode-extension
needs an update - at the very least to enable support for the new LSP v3.17 methods.However, now that the vscode-python-tools-extension-template exists I'd argue that we don't need to worry too much about showing people the "right" way to integrate a
pygls
powered language server into VSCode and we can take it in a slightly different direction.Basically I'm going to argue for converting it into a "playground"!
This PR is the start of taking things in that direction (which helped me implement #356) but I thought I'd check in before going all the way with this. Ultimately I'd like to
fountain-vscode-extension
and focus onjson-vscode-extension
- maintaining one extension is enough!examples/servers/
Let me know your thoughts! 😄
Code review checklist (for code reviewer to complete)