Writing a language server for VSCode

by @TomiTurtiainen

VSCode

No built-in language support

A set of APIs to enable rich language features

Is bundled with JS/TS, HTML, CSS, etc. language support

Hundreds of language extensions available

VSCode Language Features

  1. Declarative features
  2. Programmatic features

Declarative language features

Features like syntax highlighting, bracket matching, comment toggling, etc

Defined in configuration files

Syntax highlight

Configured using TextMate grammars

Programmatic language features

Features like auto completion, error checking, jump to definition, etc

Usually powered by a Language Server

Language Server

  • Program that analyzes your project to provide dynamic features
  • Can be used by other editors besides VSCode
  • Client (editor) communicates with it using a Language Server Protocol

Language Server Protocol

  • Open standard originally developed for VSCode
  • Standardizes how editors communicate with language servers
  • Specification available here
  • Clients available for many editors (see list here)

How Language Server Protocol works

  • Server runs as a separate process
  • Client communicates using the protocol over JSON-RPC
  • Transport can be anything, including IPC, sockets or stdio

Robot Framework

  • Automation framework mainly used for testing
  • Written in Python
  • Originally developed at Nokia Networks

Robot Framework Language Server

Features

How does it work

Parser

How to write your own?

  1. Check the VSCode API documentation
  2. Clone and play with the LSP sample
  3. Check existing implementations like the RF language server

Thank you!

Questions?