Skip to content

pisv/LSP4J_Tutorial

 
 

Repository files navigation

Build Language Servers in Java

A tutorial for EclipseCon Europe 2017

Contents

  1. Learning Goals
  2. Before We Begin
  3. Introduction
  4. Exercises
  5. Resources
  6. Next Steps

Learning Goals

  • Become familiar with LSP4J
  • Learn how to:
    • Setup a LS with LSP4J
    • Create an endpoint
    • Consume workspace files
    • Perform validation

Before We Begin

Required programs

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.

Exercise Preparation

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


Introduction

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.


Exercises

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:


Resources


Next Steps

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

  • 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!

Following this tutorial at EclipseCon 2017?

About

Build Language Servers in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%