This repository contains code to generate Language Server Protocol types and classes for various languages.
You will need a python environment to run the generator. Here are the steps:
- Create a python environment (min supported python 3.7):
python -m venv .venv - Get this tool:
python -m pip install git+https://github.com/microsoft/lsprotocol.git - Run your plugin:
python -m generator --plugin dotnet --output-dir ./code
Clone this repository and run generator like a module.
>python -m generator --help
usage: __main__.py [-h] [--model [MODEL [MODEL ...]]] --plugin PLUGIN
[--output-dir OUTPUT_DIR]
Generate types from LSP JSON model.
optional arguments:
-h, --help show this help message and exit
--model [MODEL [MODEL ...]], -m [MODEL [MODEL ...]]
Path to a model JSON file. By default uses packaged
model file.
--plugin PLUGIN, -p PLUGIN
Name of a builtin plugin module. By default uses all
plugins.
--output-dir OUTPUT_DIR, -o OUTPUT_DIR
Path to a directory where the generated content isThis project uses nox as a task runner to run the code generator. You can install nox and run build_lsp session to generate code from spec available in the repo.
> python -m pip install nox
> nox --session build_lspYou can format code, run tests, and other tasks using nox as well.
Follow these steps to generate boiler plate code for new plugin:
- Create a virtual environment for python using python 3.7 and activate that environment.
- If you have python extension for VS Code installed then run
Python: Create Environmentcommand. Be sure to select all therequirements.txtfiles in the repo. This should, install all packages needed and select the environment for you.
- If you have python extension for VS Code installed then run
- Ensure
noxis installed.- Run
nox --list, is nox is installed oyu should see a list of available sessions. Otherwise, runpython -m pip install noxfrom the python 3.7 environment you created above.
- Run
- Run
nox --session create_pluginand follow the prompts to create a new plugin.
Example:
> nox --session create_plugin
nox > Running session create_plugin
nox > Creating virtual environment (virtualenv) using python.exe in .nox\create_plugin
Enter the name of the plugin: java
nox > Created plugin java.
nox > Session create_plugin was successful.| Language | Plugin Module | Package | Notes |
|---|---|---|---|
| Python | generator.plugins.python | Active | |
| Rust | generator.plugins.rust | Development | |
| Dotnet | generator.plugins.dotnet | Development |