A work-in-progress tutorial for building a language server that complies with the Language Server Protocol. The server is written in Python using the pygls library. For more information, see the tutorial introduction.
There are two ways to use this repository:
- As documentation only: a guide for building your own language server, available here.
- As documentation and an example implementation. Clone this repo and follow along with the docs as above. Amend the server according to your needs.
These apply if you want to build/extend the server and/or docs.
Note: The instructions assume a *nix environment with a bash
shell. They should work for Linux, MacOS and Windows subsystem for Linux (WSL).
To build and run the server, you need to install vscode, git, Node.js and Python.
Then clone this repository and setup a virtual environment:
cd /my/projects/dir
git clone https://github.com/sfinnie/helloLSP
cd helloLSP
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -U pip
python3 -m pip install -r requirements.txt
Setup the nodejs environment (needed for the language client):
npm install
cd client
npm install
cd ..
If you want to run/build/change the documentation, you need a few extra packages:
python3 -m pip install -r requirements-docs.txt
- Open the project in vscode
- Run a "development" instance of the editor by typing
ctrl-shift-D
, selectingServer + Client
in the "Launch" dropdown at the top of the screen, and hittingF5
. - In the development instance of vscode, open samples/valid.greet.
- Edit the file. Valid greetings must have the form
Hello <name>
orGoodbye <name>
, where name is any contiguous string of upper or lower case letters. The server should highlight any invalid greetings.
The documentation is created with sphynx. Browsing locally is useful because it ensures all cross-references work and code samples are correctly highlighted.
cd docsrc
make html
- Open docs/index.html in your browser.
If you want to edit the documentation, you can run the live reload server. That will automatically refresh browser contents on change:
python3 run_livereload.py
- Open your browser at the specified URL (http://127.0.0.1:5500 by default)
Pull Requests welcome.