The Oxygen release train has introduced new approaches to more efficiently support editing of textual languages in the Eclipse IDE: a Generic and Extensible Text Editor was introduced in Platform to minimize boilerplate, Language Server Protocol for Eclipse (LSP4E) which allows to quickly hook into the IDE the power of Language Servers and TextMate for Eclipse (TM4E) allows to as easily delegate the syntax highlighting in the IDE to a TextMate grammar.
Those components drastically improve the “time to market” of shipping editing support for an existing language in the IDE, while keeping very close to legacy and productive workflows of the Eclipse IDE and encouraging consistency thanks to higher level of factorization.
In this tutorial, we’ll show you how to start from scratch, and build a high quality editing support for an existing programming language, relying on Language Servers and TextMate grammars; we’ll also introduce how the generic editor can be extended easily to add Eclipse-specific behavior, and how we can tweak and compose language servers with LSP4E to enrich the power of the IDE.
- Pick your favorite language with reusable Language Server and TextMate grammar
- Language which have LSP support can be found at https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Impl.... Get the language-server for your target language, install it locally and make sure you can work with it (this part is usually requires knowledge of the target language and its ecosystem, it won’t be covered by the tutorial
- Find a textmate grammar for the target language. You can usually find a “tmLanguage” file under https://github.com/textmate
- If you didn’t perform those pre-requisites research and setup, you’ll have to follow the “standard” tutorial, which will happen to be about creating an HTML (with embedded CSS and JS) editor using VSCode language server.
- Prepare an IDE
- Get an Eclipse IDE Oxygen.1 instance which is ready for plugin development (such as Eclipse IDE for RCP and RAP Developers)
- Import https://github.com/mickaelistria/eclipse-bluesky/blob/master/target-plat... , open it with the form-based “Target Definition Editor” and use “Set as Target Platform” link from this editor
- If you didn’t perform those pre-requisites steps, you’ll be provided a ready-to-use IDE with target-platform pre-provisioned in it.
- Create an Eclipse plugin
- Create a content-type for target file and associate it with Generic Editor -> Target IDE opens file with Generic Editor by default
- Create a dummy presentation reconcilier for keywords, and associate it with Generic Editor -> Target IDE shows dummy syntax in Generic Editor
- Include textmate grammar in bundle, declare it in plugin.xml, associate it with content-type, replace previous reconciler with TextMate PresentationReconiler in Generic Editor -> Rich syntax highlighting available in the IDE
- Define a language server from plugin.xml, implement the connection to LS (by consuming it as external 3rd party app for a 1st iteration) -> Language Server provides rich edition assist for the language
- Play with the editor: discover what’s featured by LSP, how LSP4E uses it, what are the limitations and the quality of your language server…
- Packaging decision and action: is referencing an external LS OK, or do we want to embed it? How to embed it? -> embedding LS doesn’t require local installation, relying on external SDK guarantees consistency with CLI...
- Completing edition support by adding an Eclipse-specific feature to Generic Editor
- Migration of existing editor to Generic Editor: Linux Tools case-study, or other existing Eclipse text editor
- Intro about creating a Language Server in Java with LSP4J and embedding it in the Eclipse IDE
- Adding another LS for the target file inside the IDE and composing it with main one
- Showcase of a LS in another IDE