Open michaeljones opened 7 months ago
Good find! It looks like this is a Helix bug rather than anything wrong in tree-sitter-gleam. The problem is this highlight pattern: https://github.com/gleam-lang/tree-sitter-gleam/blob/62c5388a7badb4e29315690358267a76a734bf83/queries/highlights.scm#L17-L20
Also see #7: tree-sitter previously did not allow us to gate more than one capture (@module
and @function
) behind the #is-not? local
predicate. As a result, connection
is always tagged as a @function
even if config
is a local. We fixed the behavior of that pattern a while ago upstream in tree-sitter but I never ported the necessary change to the highlighting code to Helix (https://github.com/tree-sitter/tree-sitter/pull/1602/files#diff-538bdc046297d41717e7a863a54456d47829fb2e298963198cdfb32684500cdd). I'll make a PR for that change in Helix.
I have the same behaviour in Neovim. Do they have the same bug?
I would bet that nvim also needs to add the equivalent of QueryMatch::remove
in their locals calculation. (For nvim I believe it would be ts_query_cursor_remove_match
since they use the C bindings.) I can take a look at fixing that in nvim as well
Ah actually it looks like nvim is using different highlights https://github.com/nvim-treesitter/nvim-treesitter/blob/cd4e0909948eb33d3959e133c16f837e4db122c6/queries/gleam/highlights.scm
And nvim doesn't support #is-not? local
yet: https://github.com/nvim-treesitter/nvim-treesitter/blob/97997c928bb038457f49343ffa5304d931545584/queries/ruby/highlights.scm#L165-L167
So nvim might need a different fix for its highlights
When I have code like:
in a case statement, the syntax highlighting fails on the second
.
inconfig.connection.host
.Louis was able to reproduce it and I did my best to check with the latest commit from this repo via an entry in the Helix
languages.toml
.Grateful for Gleam, this project and Helix :)