Xtext VS Code example

November 3, 2016 ยท View on GitHub

This is a simple example showing the Xtext integration for VS Code based on the Microsoft Language Server Protocol.

The base is following simple grammar

Model:
    greetings+=Greeting*;
    
Greeting:
    'Hello' name=ID ('from' from=[Greeting])? '!';

A typical example model would look like (Open a new folder in VSCode and create the files)

a.mydsl

Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!
Hello you!

b.mydsl

/* this is a definition in another file */
Hello Other!

The Xtext integration supports typical Xtext and Language Server features like

  • Syntax Highlighting
  • Validation
  • Goto Definition / Find References
  • Hover
  • Formatting
  • Mark Occurrences
  • Open Symbol

A introductory article can be found here