LSP implementation for Crystal on Windows

The tooling for Crystal on Windows is not good. I am working on a language server and VSCode extension that leverages the existing CLI tools available and incorporates them into an instant-response context so as to achieve features such as autocomplete, real-time error detection, etc… on Windows, since Crystalline and Scry seem to be for POSIX platforms only.

Demo of its current capabilities can be observed here

Source code is here, you can build the vsix for the vscode extension with “npm run package”, and the server itself with “shards build”.

3 Likes

I agree completely with your opening sentence. I hope you get some good traction with this.

Looks like your source repo is not public, I’m getting a 404 error.

Should be public now.

Does it support use under Linux?

It does.

1 Like

Okay, thanks, build successful on my Arch linux.

How to use that? there is no any cli options available for bin/liger

should I run liger or liger --stdio ?

EDIT: It’s seem like liger --stdio work!

just run liger with no arguments, for helix this is my configuration, differs for neovim, etc… and theres a vscode extension bundled in the repo to build a VSIX if you use vscode.

[language-server.liger]
command = "liger"

[[language]]
name = "crystal"
scope = "source.cr"
file-types = ["cr"]
auto-format = true
language-servers = ["liger"]

Hi, I use Emacs, I consider add a –-stdio (which following previous crystalline/scry) is better.

Anyway, user probably what to know what is the version of current server, maybe introduce opt_parser is better too.

Please check here for emacs config.

Hi, jump to file definition not work well as crystalline.

e.g. when try to jump here, will jump to lib/lucky/src/lucky/tags/specialty_tags.cr:3 if used with crystalline, but not work when used with liger.

Another issue is when editor is terminated, liger should be kill too.(it does when use with crystalline)

And, liger keeping very high CPU usage (even after half of one hour)

If you open issues for those on github i’ll get around to fixing them.

Also how are you getting Crystalline to show hover results? For me I dont get anything from Crystalline.

Seems like it should just work. Works in Zed anyway.

Btw to get this working in Zed:

{
  "languages": {
    "Crystal": {
      "extend_comment_on_newline": false,
      "formatter": {
        "external": {
          "arguments": ["tool", "format", "-"],
          "command": "crystal",
        }
      },
      "language_servers": ["crystalline", "ameba-ls", "typos", "cspell"],
    }
  },
  "lsp": {
    "crystalline": {
      "binary": {
        "path": "/Users/youruser/.local/bin/liger",
      },
    }
  }
}

Just have to make the Crystal extension think it’s crystalline.

I can add support for liger to the zed extension if people desire.

For Neovim user:

  • fennel config

(vim.lsp.config :liger

{:cmd ["liger"]

:filetypes [:crystal]

:root_markers [:shard.yml :.git]})

OR

  • lua config

vim.lsp.config("liger", {cmd = {"liger"}, filetypes = {"crystal"}, root_markers = {"shard.yml", ".git"}})

Just tried zed with the crystal extension and claude and congrats, that thing is looking great.