VSCode - Pharo

Posted by Benoît "badetitou" Verhaeghe on January 7, 2021

VSCode Pharo is an extension that enables the support of the Pharo programming language in Visual Studio Code.

This page is announcing the creation of the extension, it might not be up-to-date. Please see the GitHub repository for more information.

Here, we are detailing how to set-up VSCode to use the extension, then we present the main features of the extension, and future features.

Installation

Five steps are required to install the plugins.

  1. Install VSCode
  2. Install the Pharo extension
  3. Download a Pharo Language Server image or install the server in a pre-existing image
  4. Download a VM (headless or not) for the image
  5. Set up the Pharo extension property
    1. pharo.pathToVM: is the path to the VM executable
    2. pharo.pathToImage: is the absolute path to the image

Features

We present here the existing features

Generic feature

  • Code highlighting

Highlighting

Supported Language Server feature

  • Code formatting

Format gif

  • Hover

When moving a cursor over a class, it shows the comment of the class. The hover popup supports markdown. So it can be use to print nice comment from Pharo 9.

Hover

  • Auto-completion

We used the completion engine of Pharo to compute the entries. Not that for keywords with several symbols, it is possible to use the <Tab> key to move from one argument to another.

Auto-Completion

Additional feature

The additional feature can be access using the command palette of VSCode

  • Save the Pharo image
  • Execute and show the result

Inspect gif

  • Execute and print the result

Print gif

  • Keep variable state

Keep Variable state gif

  • Show the current server version

Show version gif

  • Saving a tonel file in VSCode, save the corresponding methods/class in the Pharo image

Future

Three major features are coming (and will require time).

  1. Synchronization
    1. From Pharo to VSCode
    2. From VSCode to Pharo
  2. Debug Adapter Protocol
  3. Notebook (VSCode preview)

Synchronization

We plan to add commands to VSCode to allow synchronization between Pharo and VSCode. The idea is to be able to install a set of classes from the VSCode editor inside the opened Pharo Image. A typical use case is then:

  1. Clone from git a Pharo project
  2. Open the project in VSCode
  3. Synchronize the project with the image
  4. Developing :rocket:

Another possibility will be to synchronize a project already present in the image with a ongoing VSCode session. A typical use case is then:

  1. Open VSCode
  2. Install a project using Metacello with a VSCode command
  3. Synchronize the interesting projects inside the VSCode editor
  4. Developing :rocket:

Debug Adapter Protocol

Debug Adapter Protocol (DAP) is a generic protocol that can be used to control debugger. We plan to add support of the DAP over our extension. With this extension, it will be possible to debug Pharo application using several editors (VSCode, Emacs, Vim, Eclipse, …).

Notebook

VSCode is currently testing a Notebook feature (as Jupyter). We already have most of the required material to implement a Pharo Notebook using the VSCode API. This will be our priority as soon as the stable VSCode notebook API will be released.

Posts

Analysing Java with VSCode

How to use VSCode and Moose to analyse Java projects?

Dev - Pharo Language Server

Description of the Language Server Protocol for Pharo