New version of my language server

Hey!

I’ve added a bunch of updates to the elm-language-server I’ve created, some cool gifs to show off the various features.

I created it with the goal of having something as fast and reliable as the Elm compiler to use in editors on a specific large codebase (~300klc + another ~300kloc of generated code), where existing solutions did not cut it.

Since last time I talked about it on elm-slack, support for document symbols, formatting (via elm-format) and the ability to rename some things, along with various fixes to existing systems, have been added.

If you want to try it out, I’ve got a binary for apple silicon in the release, since that’s what I use myself. There are instructions with the versions of Haskell tools that can be used and also instructions for building it with Nix.

For what’s next, I intend to look into improving caching and am considering hover type inference.

https://github.com/WhileTruu/elm-language-server
https://github.com/WhileTruu/elm-language-server/releases/tag/v1.0

Let me know what you think! :slight_smile:

18 Likes

600kloc of Elm, this is pretty impressive. What king of product are you developing ? How many views, message types, do you have ?

1 Like

It’s an accounting kind of a product. We have about 250 pages (Model, init, Msg, update, view), a few kind of just wrap common components used between multiple pages.

1 Like

Hi,

A smart move I think to base it off the Elm compiler, as that already has so much of what a language server needs.

Which IR does your language server use, is it the Canonical IR ?

I know my way around the compiler code quite well from working on the Guida Elm port - which areas would I look in to see the bulk of the language server code you have added ? Just curious to take a look and see.

It uses the source AST for all the features. I’ve done a proof-of-concept level type inference thing, that requires doing things with the canonical representation.

I also recently removed warnings (missing types, unused imports and such), which were based on canonical and optimized stuff. I think that functionality was copied from elm-dev, and too slow for the way the server currently works.

I’ve tried to keep changes to the actual compiler to a minimum, just exposing functions mostly. Almost everything is in just one file elm-language-server/terminal/src/LanguageServer.hs at language-server · WhileTruu/elm-language-server · GitHub, there’s also a small reporting file in a folder with the same name as that file.

1 Like

Has anyone tried to set this up with Zed? That’s been my editor for some years now and would love to try out this language server.

I’m trying it out on my system. It has the same name as the regular elm-language-server, so I didn’t have to change anything in my editor (helix) to use it.

3 Likes

I’ve added some updates and published a version with linux x86 and arm binaries as well, although I only tested the macos one.

  • diagnostics now run on a different thread and are debounced, so saving a bunch of files at the same time is more pleasant
  • support for references and go to definition for more things, which also adds rename support for more things

@wolfadex I got it working with Zed, I needed to add jsonrpc version to messages and the config below:

"lsp": {
    "elm-language-server": {
      "binary": {
        "path": "absolute path to binary",
        "arguments": [],
      },
    },
  },

Zed was really slow to show references for me, it got them in under a second from the server and then took like 30 to display them. Not sure what that is about.
I haven’t created a release / binaries for the jsonrpc version commit yet.

2 Likes