A tutorial for EclipseCon Europe 2017
- Become familiar with LSP4J
- Learn how to:
- Setup a LS with LSP4J
- Create an endpoint
- Consume workspace files
- Perform validation
We will be using Eclipse IDE for Eclipse Committers, which includes everything that is needed to work through the tutorial. Eclipse is not mandatory for lsp4j, but included in this repository is an Eclipse Plugin to allow testing your language server.
This is an interactive tutorial, if you are viewing this on GitHub, download the project now to be able to follow along with the exercise. Within Eclipse use File > Open Projects from File System to import the required projects by setting the Import source to the LSP4J_Tutorial
directory by using the Directory... button
- LSP4J_Tutorial/Eclipse_LS_Plugin
- LSP4J_Tutorial/Exercises/solution
- LSP4J_Tutorial/Exercises/1
- LSP4J_Tutorial/Exercises/2
- LSP4J_Tutorial/Exercises/3
- LSP4J_Tutorial/Exercises/4
This tutorial will not go over the Language Server Protocol itself, if you are unaware of what the LSP is, refer to its GitHub page or read the actual protocol.
LSP4J (Language Server Protocol for Java) is an Eclipse project which provides Java binding for the Language Server Protocol. The LSP is based on an extended version of JSON RPC v2.0, for which LSP4J provides a Java implementation. Therefore, we are able to use it to create a language server without having to deal with the JSON specifics of the LSP and instead create endpoints for which we are given parameters from the client and return the required actions in object form based on which message our server receives.
In this tutorial, we are using LSP4E (Language Server Protocol for Eclipse) to consume and interact with our language server, however, as the value of language servers, the server you develop within this tutorial can be used by any IDE.
Each exercise is contained in the org.eclipsecon.lsp4jtutorial.exercises
package and each is its own Language Server that can be tested on it's own file type:
The Language Servers used in the previous exercises are all set up to be Eclipse plugins. In this repo there is a template Language Server written in Java using LSP4J made to be compiled to a jar and ran from any IDE, which you can use to begin work on your next LSP project!
Other things that you can do to continue your LS involvment:
-
Work on an existing LS or LS client
- Here is a list of existing language servers and clients (Bottom of page) as most are open to PRs
-
Develop your own
- There are tons more of file types and languages that currently do not have a LS, you can change that!
-
Develop an Eclipse LS plug-in
- Such as aCute (which is always looking for new committers), make a plug-in to add IDE specific features to compliment a LS
🍴 Feel free to fork this repo and run your own tutorial!