Closed alcarney closed 9 months ago
It works!
Loading up VSCode from within a source env/bin/activate
shell just automatically finds the right Python interpreter now π₯³
2023-09-14 18:02:22.536 [info] Extension activated.
2023-09-14 18:02:22.536 [info] python env modified, restarting server...
2023-09-14 18:02:22.536 [info] cwd: '/home/tombh/Workspace/pygls/examples/servers'
2023-09-14 18:02:22.536 [info] server: 'json_server.py'
2023-09-14 18:02:22.536 [info] Looking for environment in which to execute: 'file:///home/tombh/Workspace/pygls/examples/servers/json_server.py'
2023-09-14 18:02:22.536 [info] Found environment: /home/tombh/Workspace/pygls/env/bin/python: /home/tombh/Workspace/pygls/env/bin/python
2023-09-14 18:02:22.757 [info] client options: {
"documentSelector": [
{
"scheme": "file",
"language": "json"
}
],
"outputChannel": {
"name": "pygls",
"logLevel": 3
},
"connectionOptions": {
"maxRestartCount": 0
}
}
2023-09-14 18:02:28.097 [info] Validating json...
And when I make an error in the test.json
it seems I get 2 sets of diagnostic reports, I assume one of them must be the example server. The other must come by default with VSCode?
But I spent a long time trying to get the Code Actions and Inlay Hints to work, because I didn't realise that I had to edit the settigns.json
file π¬ Coming from the Neovim world I thought I had to find a keyboard shortcut to show the Code Actions popup, and that I had to enable Inlay Hints in some global settings. So I think it'd be good to very briefly explain how to run each of the example servers and what to expect when each one does run.
This is so awesome!!
It works!
Glad to hear it!
Loading up VSCode from within a source env/bin/activate shell just automatically finds the right Python interpreter now
Would you mind quickly trying it with the venv
deactivated also? In an ideal world the extension shouldn't require you to open VSCode in any special way. (Though you might have to use the Python: Select Interpreter
command as a first time setup step)
And when I make an error in the test.json it seems I get 2 sets of diagnostic reports, I assume one of them must be the example server. The other must come by default with VSCode?
Yes :)
So I think it'd be good to very briefly explain how to run each of the example servers and what to expect when each one does run.
Ok, I'll look at expanding on the README a bit more - do you mind if I pinch your screenshots?
I had a bit of a play without using the venv's activate
and couldn't get it to work. I think the basic fact is that VSCode's Python extension can only find the env/bin/python
interpreter when VSCode is opened in the root of the project (therefore the parent of .git/
and env
).
This is what I see when opening VSCode in examples/vscode-playground
:
And this is what I see when opening VSCode from the project root:
I think the basic fact is that VSCode's Python extension can only find the env/bin/python interpreter when VSCode is opened in the root of the project (therefore the parent of .git/ and env).
Oh! It's amazing what rough edges you gloss over when you're used to something. π
That's how it works for me as well. You should be able to use the Enter interpreter path
option to get a file open dialog and manually set the path to the python exe for the playground to use π€
Once setup VsCode should remember the choice for future sessions.
Another step to go in README...
Alternatively....
Perhaps it's better to move the launch.json
file for the playground into the root of the repo... and try and set things up so that people don't have to open VSCode in a subfolder at all π€
Oh! It's amazing what rough edges you gloss over when you're used to something. π
OMG I know, so true π
You should be able to use the
Enter interpreter path
option to get a file open dialog and manually set the path to the python exe for the playground to use π€
It doesn't seem to in my case. Again, I might be doing something wrong, but even once I've selected the ./env/bin/python
from a VSCode instance opened in the examples/vscode-playground
folder, I still get the No module named 'pygls'
error π«€
Perhaps it's better to move the launch.json file for the playground into the root of the repo
Hmm, yes, I suppose that might be what's needed.
Again, I might be doing something wrong, but even once I've selected the ./env/bin/python from a VSCode instance opened in the examples/vscode-playground folder, I still get the No module named 'pygls' error π«€
So strange! :/
@karthiknadig I don't suppose you'd able to take a quick look at this function and see if I'm missing anything obvious. It should allow people to use Python: Select Interpreter
to configure the Python envrionment to use with pygls
, but it doesn't seem to work for anyone except me! :sweat_smile:
Otherwise, I'll look into moving things around.
When calling getActiveEnvironmentPath
is it called with the workspace.uri
or some uri
from the current workspace. If it is called with undefined it can fail to get selected python.
@tombh I wonder if we should merge this?
I did have a go at moving the launch.json
file to the root of the repo, but VSCode didn't seem to want to launch a debug instance in the same folder as the main instance :/
At the very least the simplified folder structure should be an improvement and we have a few workarounds if discovery fails
pygls.server.pythonPath
option to override the automatic discovery mechanismIdeally it should Just WorkTM, but I'm not sure what else to try at this point
Sure, let's merge it. I think they're relatively minor issues really. The main thing is that there are workarounds. And having it merged might give it more exposure and more feedback and ideas.
Shall I merge this then? π
@tombh go for it :)
Done. And a little point release as well to celebrate?
Aren't we waiting to hear back about the impact of #411?
@alcarney I will provide an Update on #411 by end of the day for me (which is Pacific time)
Description (e.g. "Related to ...", etc.)
This attempts to fix the issues seen in #357 @tombh @z80dev, would you mind trying this out and seeing if it fixes your issues?
examples/workspace/
into theexamples/servers/
directory.examples/servers
folder by defaultpygls.server.pythonPath
option to override the interpreter selection made by the extension (basically how thejson-extension
used to work)settings.json
file is now included so should be easier for the user to start tweaking valuesThere was also a bug in how the
json_server.py
handled theworkspace/diagnostic
request when no documents were open - that should be fixed nowCode review checklist (for code reviewer to complete)