helix: Problem when adding a language server to the Cairo language

Hi all:)!

I’ve recently picked up Helix and love it! Thanks a lot. Been using it as my main Rust IDE 🦀.

I’m currently working in the Starknet ecosystem and their programming language is Cairo. I saw that in the default language config, Cairo is already mentioned. Nonetheless, there is no language server associated.

I tried to override the basic config with the following language config (~/.config/helix/languages.toml):

[[language]]
name = "cairo"
scope = "source.cairo"
injection-regex = "cairo"
file-types = ["cairo"]
indent = { tab-width = 2, unit = "  " }
comment-token = "#"
language-server = { command = "cairo-ls" }

Where I aliased cairo-ls in my .zshrc to be: alias cairo-ls="node ~/code/lsp/node_modules/cairo-ls/out/server.js --stdio"

As the cairo language server does not have a binary but rather a node script: https://www.npmjs.com/package/cairo-ls

When trying to open a .cairo file, Helix informs me that there is no language server running.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

We spawn the language server directly as a child process instead of using a shell so the language-server configuration won’t find commands from shell aliases. It should work to create a wrapper script that executes that command and to add that to your $PATH, or you can configure that node command:

# ~/.config/helix/languages.toml
[[language]]
name = "cairo"
language-server = { command = "node", args = ["~/code/lsp/node_modules/cairo-ls/out/server.js", "--stdio"] }