Introducing the Pine VS Code extension and Elm language server

As published on my blog at https://michaelrätzel.com/blog/introducing-the-pine-vs-code-extension-and-elm-language-server

Hi all :wave:

I published a VS Code extension integrating Elm developer tools and language services.

It’s available in the VS Code extension marketplace at https://marketplace.visualstudio.com/items?itemName=Pine.pine

This new tool packages the features found in the Elm Editor project for reuse in VS Code. While Elm Editor is a standalone environment optimized for minimal setup, the VS Code extension is for integration in existing development setups.

One key difference from other implementations of VS Code extensions is that the language services are written entirely in Elm.

Another innovation is that instead of compiling from Elm to JavaScript, it runs on a new kind of virtual machine. (More on that soon)

Note that this tool is in an early stage of development. You will see some lag depending on the number and size of Elm modules.

A snapshot of the features as of today:

  • Syntax highlighting
  • Formatting
  • Error highlighting
  • Completions - Shows completion suggestions matching the current context
  • Hover tips - Shows type annotations and documentation for a type alias, module, type, or function
  • Go to Definition - Jump to the definition of a type alias, module, type, or function
  • Go to symbol - module outline
  • Find All References

The VS Code extension is a thin wrapper for connecting to a language server, packaging the above-listed functionality. It uses the language server protocol, which should make reusing that part in other code editors easier.

Building these tools wouldn’t have been possible without the many excellent libraries and tools developed by others over the years. A special shoutout to Mats Stijlaart, Jeroen Engels, @lue-bird, and everyone else contributing to the ongoing development and improvement of the elm-syntax package. I especially enjoyed the performance optimizations introduced in 2024, which greatly improved response times!

Outlook

One feature I have planned to add in the future is viewing and running tests via the GUI.

Besides that, I am working on more optimizations to improve response times and support larger codebases.

I’d love to hear your thoughts and experiences!

Here’s to a fantastic year ahead for Elm development. Happy coding! :rocket:

21 Likes

Great work Viir! I look forward to trying it out.

Do you think it would be feasible in the future to add a “rename” action? That is the one feature of the existing Elm Language Server that I would now find it difficult to live without as I am terrible at naming my types and variables and always want to rename them.

3 Likes

Hey Ed!
Thanks for the input. Knowing this, I can prioritize adding the rename action. My first impression is that I will have to work on the internal workspace model to make such refactoring actions feasible, but I will keep that in mind!

3 Likes

Well, now I am intrigued…!

2 Likes

Well, now I am intrigued…!

The summary is this: The Pine virtual machine is a replacement for NodeJS/V8 for applications adhering to the Elm architecture.

It might be too early to introduce that solution here because it’s not yet as easy to use.

3 Likes

@edkelly303 @paulh, the rename action is now available, starting with version 0.3.30 of the language server. (The language server is shipped with the binary installed separately from https://pine-vm.org/download, so updating only the VS Code extension is not enough to enable the new feature)

Implementing the renaming of a symbol across files turned out to be straightforward. As @lydell pointed out on Discord, it can be built on top of the implementation to ‘Find All References’

To make renaming work, I had to make a few adjustments to the internal model tracking declarations. One change is a more precise tracking of source code ranges in declarations. For example, if a function declaration is annotated, it has more than one range representing its name, and that aspect had not been part of the previous model.

7 Likes

That is awesome, thank you so much! I’m glad it wasn’t too difficult to implement.

1 Like

Very intriguing! May I ask, is the LS going to be distributed as a CLI too? For us who prefer editors other than VS Code, if possible.

3 Likes

Absolutely! You can run the Elm language server using the general Pine CLI.
You can use the subcommand lang-server together with option --stdio to start the language server with the stdio connection mode:

pine  lang-server  --stdio

(‘StdIO’ is the most commonly used mode for language servers running locally on the same machine)

With this command line, the language server should also work in other editors.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.