openlawlibrary/pygls

Unclear tutorial example for running `json_server.py` in debug mode

Opened this issue · 6 comments

Howdy - I am currently attempting to follow along with the tutorial using the VSCode extension setup provided by vscode-playground, but am running into a snag with getting debugging working properly.

Following the instructions specified here works fine for opening up a second VSCode window where the langauge server as defined in json_server.py can be played with. However, when attempting to add breakpoints and interact with this code using the debugger as we are told to do in the tutorial doesn't seem to work.

With very limited experience working with VSCode extension development, my best guess as to what is going on is the Launch Client configuration in the launch.json included in the vscode-playground example only launches the extension, the extension launches the language server, and the initial VSCode debugger instance is not attached the language server launched by the extension? It seems like what would need to happen in that case is some additional configuration in the launch.json to specify how the debugger attaches to the language server, but I haven't been able to figure that out.

In any case, I would appreciate any clarification on how this is intended to work.

Environment details

  • main branch of pygls at commit 936e653
  • Python 3.11.6
  • VSCode 1.85.1

Apologies... the playground was recently rewritten and the docs haven't quite caught up with the new setup yet. 😅

I've just opened #425 which should automatically handle setting up a debug session for you, if you fancy giving that a try?
Assuming you already have the Python extension installed, setting the pygls.server.debug option to true should be all you need to get going.

The docs in general need a bit of attention so hopefully I can get the tutorial realigned in the not-too-distant-future.

Let me know if you run into any issues.

Just pulled down the changes and was able to follow along and get it working! Appreciate the quick response.

Not sure if I should throw this on here or not, but in the immediately following section of the tutorial where it states

Press F1, find and run Count down 10 seconds [Blocking] command.

I can't seem to find any command like this in the command window -- not sure if this is related to the above or anything, but figured I'd flag it -- happy to make a new issue if you want.

Just pulled down the changes and was able to follow along and get it working!

Glad to hear it!

I can't seem to find any command like this in the command window...

Another symptom of the docs falling behind I'm afraid.

Now that the playground tries to support any server you could write with pygls, it can't expose the commands in VSCode directly. Instead it offers a generic pygls: Execute Command command, which will present you with a list of commands defined by your current server which you can choose to run.

So the tutorial should now say something like

F1 -> pygls: Execute command -> countDownBlocking

Please do keep flagging issues like this, it's very helpful!

Appreciate the clarification! I'll follow up on this issue if I encounter any other points of confusion in the tutorial/user guide.

Thanks! I am playing around with the tutorial and run into similar issues. This post help me to solve some of the problem. On the other hand I had some weird issue when running pygls==1.3.0 with the tutorial, downgrading to 1.2.1 seem to avoid the problem.