Skip to content

Commit

Permalink
refactor: Rename json-vscode-extension/ -> vscode-playground
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alcarney committed Aug 14, 2023
1 parent 3c44a15 commit 85d8327
Show file tree
Hide file tree
Showing 18 changed files with 641 additions and 341 deletions.
53 changes: 0 additions & 53 deletions examples/json-vscode-extension/.vscode/launch.json

This file was deleted.

24 changes: 0 additions & 24 deletions examples/json-vscode-extension/README.md

This file was deleted.

104 changes: 0 additions & 104 deletions examples/json-vscode-extension/client/src/extension.ts

This file was deleted.

82 changes: 0 additions & 82 deletions examples/json-vscode-extension/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions examples/json-vscode-extension/tsconfig.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/servers/json_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,4 @@ def main():


if __name__ == "__main__":
logging.basicConfig(filename="pygls.log", level=logging.DEBUG, filemode="w")
main()
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions examples/vscode-playground/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Client",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--folder-uri=${workspaceRoot}/../workspace",
"--folder-uri=${workspaceRoot}/../servers",
],
"outFiles": [
"${workspaceRoot}/out/**/*.js"
],
// "preLaunchTask": {
// "type": "npm",
// "script": "compile"
// },
},
],
}
File renamed without changes.
File renamed without changes.
47 changes: 47 additions & 0 deletions examples/vscode-playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Pygls Playground

This VSCode extension aims to serve two purposes.

- Provide an environment in which you can easily experiment with the pygls framework by trying some of our example servers - or by writing your own

- Provide a minimal example of what it takes to integrate a pygls powered language server into VSCode.

For an example of a more complete VSCode client, including details on how to bundle your Python code with the VSCode extension itself you may also be interested in Microsoft's [template extension for Python tools](https://github.com/microsoft/vscode-python-tools-extension-template).

## Setup

### Install Server Dependencies

Open a terminal in the repository's root directory

1. Create a virtual environment
```
python -m venv env
```

1. Install pygls
```
python -m pip install -e .
```

### Install Client Dependencies

Open terminal in the same directory as this file and execute following commands:

1. Install node dependencies

```
npm install
```
1. Compile the extension

```
npm run compile
```
Alternatively you can run `npm run watch` if you are going to be actively working on the extension itself.

### Run Extension

1. Open this directory in VS Code
1. Open debug view (`ctrl + shift + D`)
1. Select `Launch Client` and press `F5`
Loading

0 comments on commit 85d8327

Please sign in to comment.