bscan / RakuNavigator

Raku language support and language server
MIT License
51 stars 3 forks source link

Syntax highlighting in Helix #22

Closed biskwikman closed 2 months ago

biskwikman commented 2 months ago

I've gotten errors to appear but I can't get syntax highlighting to work in Helix. Is there something I'm missing in my languages.toml?

[language-server.rakunavigator]
command = "node"
args = ["/home/dan/Programs/RakuNavigator/server/out/server.js", "--stdio"]

[[language]]
name = "raku"
scope = "source.raku"
file-types = ["raku", "rakudoc"]
comment-tokens = "#"
language-servers = ["rakunavigator"]
bscan commented 2 months ago

Hi @biskwikman. Unfortunately, Helix only supports syntax highlighting via tree-sitter grammars, and I'm not aware of any tree-sitter grammars for Raku. There's a bit of discussion here: https://github.com/Raku/problem-solving/issues/422

It's also possible for Language Servers to do syntax highlighting via Semantic Tokens, which allow richer highlighting than can be found via text analysis. For example, when importing symbols, a language server is often needed to understand the type of the symbol. Unfortunately, Helix does not currently support Semantic Tokens (see https://github.com/helix-editor/helix/issues/10343 for more details), and it seems like it will never support LSP-only highlighting. It will always require a tree-sitter grammar that may eventually be augmented with information from a Language Server.

And anyway, the Raku Navigator doesn't currently provide Semantic Tokens. The highlighting provided for vscode is through a textmate grammar and occurs outside of the Language Server. Within the Language Server, it is doing some limited internal tokenizing (e.g. while building the outline view), but these tokens are not currently exposed as Semantic Tokens.

biskwikman commented 2 months ago

Thanks for all the info @bscan. Very helpful.