Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two dots in guard clause cause syntax highlighting issue in Helix #81

Open
michaeljones opened this issue Jan 20, 2024 · 4 comments · Fixed by helix-editor/helix#9390
Open

Comments

@michaeljones
Copy link

When I have code like:

    http.Get, [".well-known", "webfinger"] ->
      case host {
        value if value == config.connection.host -> web_finger_page(req, config)
        _ -> wisp.not_found()
      }

in a case statement, the syntax highlighting fails on the second . in config.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 :)

the-mikedavis added a commit that referenced this issue Jan 20, 2024
@the-mikedavis
Copy link
Member

Good find! It looks like this is a Helix bug rather than anything wrong in tree-sitter-gleam. The problem is this highlight pattern:

((field_access
record: (identifier) @module
field: (label) @function)
(#is-not? local))

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.

@lpil
Copy link
Member

lpil commented Jan 21, 2024

I have the same behaviour in Neovim. Do they have the same bug?

@the-mikedavis
Copy link
Member

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

@the-mikedavis
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants