Skip to content

badetitou/Pharo-LanguageServer

Repository files navigation

Pharo Language Server

Continuous Pharo 12 Moose version Coverage Status

I am an implementation of the Language Server Protocol (LSP) for the Pharo programming language. My main goal is to provide a unique interface for several generic IDE to manipulate a Pharo environment.

I am used by the following client extensions:

If you experiement with other IDE, do not hesitate to contact us in an Issue :)

Features

As a language server, I accept two Pharo/SmallTalk formats:

  • .st for smalltalk script (as you can see in a playground).
  • .class.st for tonel files.

Most of the features are available for both formats.

  • Code highlighting
  • Hover
  • Auto-completion

Script specific features

  • Code formatting

Tonel specific features

  • Saving the file create/update the corresponding class in the image

Installation

Execute this code in any Pharo10/11 Image

Metacello new
  githubUser: 'badetitou' project: 'Pharo-LanguageServer' commitish: 'v5' path: 'src';
  baseline: 'PharoLanguageServer';
  load

Or download a pre-existing image in the release section.

Usage

Once you have an image with the project installed, you can run it using

/path/to/vm/pharo [--headless] /path/to/pls.image st /path/to/run-server.st

In above example, we used an another file named run-server.st that is used to define the Pharo script that run the code. You can find the definition of this file for the vscode extension and for the eclipse extension.

Basically the file looks like this

| server |
"Stop and reset potential existing instance in the image you start"
PLSServer reset.
"Create a new Language Server"
server := PLSServer new.
"Start the new language server"
server start.

By default, the server will start a socket and give you the port of the opened socket in the standard output. If you want to use standard input/ouput to deal with communication, you can use the folowing option:

server := PLSServer new
  withStdIO: true;
  yourself

This option is less tested and might create bug with Pharo writing to the standard output for other reason