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

Attach attributes to their associated node #70

Closed
wants to merge 2 commits into from

Conversation

deriamis
Copy link

In the previous version of the grammar, attributes essentially "floated"
in the tree, meaning they were not actually attached to anything. This
was causing odd issues with syntax highlighting, such as external
functions marked with an @external attribute causing subsequent
syntax highlighting to fail in source files. This commit attaches
attribute nodes only to legal parent nodes (functions and statement
blocks) to make syntax highlighting more consistent.

Closes #69

In the previous version of the grammar, attributes essentially "floated"
in the tree, meaning they were not actually attached to anything. This
was causing odd issues with syntax highlighting, such as external
functions marked with an `@external` attribute causing subsequent
syntax highlighting to fail in source files. This commit attaches
attribute nodes only to legal parent nodes (functions and statement
blocks) to make syntax highlighting more consistent.

Closes gleam-lang#69
@@ -27,7 +27,7 @@
},
"homepage": "https://github.com/J3RN/tree-sitter-gleam#readme",
"dependencies": {
"nan": "^2.15.0"
"nan": "^2.18.0"
Copy link
Author

@deriamis deriamis Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses nodejs/nan#942, which causes npm install failures on some platforms.

@lpil lpil requested a review from a team September 19, 2023 11:47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this will give tree-sitter better hints for error recovery. Plus we lose the ability to highlight attributes on their own - it's not important when parsing a complete/correct gleam file but it's a case that will come up as-you-type and if you want to show a snippet for just an attribute, like:

```gleam
@external(erlang, "erlang", "integer_to_list")
```

in a github comment for example.

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 this pull request may close these issues.

Inconsistent syntax highlighting
2 participants