-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add to GitHub #14
Comments
We'll need I can take a look at adding these, I bet it wouldn't be too tough given how the nodes are structured 👍 |
Hi @lpil! Sorry for the delay. As @the-mikedavis said, the parser is in pretty good shape. I have a few items on my shortlist:
New one: And also Somewhat related, but I think we should move the canonical version of this repository to under the github.com/gleam-lang organization once those are done, but before we ask for it to be used with GitHub. I'll post updates here; I'm hoping to get my shortlist done this evening 😁 |
All sounds fab to me! |
Hey @lpil, sorry for the delay! The repository is now at a good point to transition ownership to under the gleam-lang org. Whether you want to fork it to that org or clone-and-push a copy is totally up to you! Once it's over there, I'd love if you could add myself and @the-mikedavis as maintainers of the project, and it should also be ready to provide to GitHub for integration 🙏🎉 |
I remember transferring a repo to be a bit strange when working on |
Ah, I didn't even think about GitHub having an official mechanism for this! 😅 Sure enough, I tried requesting a transfer to gleam-lang, but that didn't work as it said I didn't have access to create repositories for gleam-lang. I have now requested a transfer to @lpil, such that he can then transfer it to gleam-lang. |
Hey @lpil! Just wondering if we've reached out to the team at GitHub about adding tree-sitter-gleam functionality to their platform. If not we can cc them here 😁 |
👋🏻 GitHubber here. We’ve added Gleam support to our roadmap. I can’t make guarantees as to a timeframe, unfortunately, but we’re on the case! |
Amazing, thank you @patrickt !! |
We’ve just integrated |
@patrickt Great news! Though to me it doesn't look quite right. We have lost syntax highlighting for types and constructors, and labels and arguments are two different colours now. The orange module names stand out a lot more than I think is ideal too. In this snippet I think they are not very important but they are very bold. Previously they were white, like variables. Is this something we can fix on our end? |
Found a few more places in which syntax highlighting is broken: Type definitions are no longer highlighted Strings with |
FWIW, the general non-highlighting of types (and data constructors/names, which we treat as types for better or for worse) appears to be an issue on GitHub's side. Those use the We also verify this in some of our highlighting tests. The "comment in string" bug is real and affects environments other than GitHub. I'll try to run that down this evening. |
To give a small update on this, the string/comment parsing issue appears to be an artifact of parsing strings as non-terminal nodes/tokens, which means that any field in To counter this, I tried wrapping the string child nodes with
It may truly be specific to whitespace, because it had no effect. My approach looks like this: string: ($) =>
seq(
'"',
repeat(choice($.escape_sequence, $.quoted_content)),
token.immediate('"')
),
escape_sequence: ($) => token.immediate(/\\[efnrt\"\\]/),
quoted_content: ($) => token.immediate(/(?:[^\\\"]|\\[^efnrt\"\\])+/), FWIW, tree-sitter-rust's approach is very similar: string_literal: $ => seq(
alias(/b?"/, '"'),
repeat(choice(
$.escape_sequence,
$._string_content
)),
token.immediate('"')
),
// ...
escape_sequence: $ => token.immediate(
seq('\\',
choice(
/[^xu]/,
/u[0-9a-fA-F]{4}/,
/u{[0-9a-fA-F]+}/,
/x[0-9a-fA-F]{2}/
)
)), A notable difference, however, is that tree-sitter-rust's |
With respect to the queries: The locals scope for functions was not large enough, so a function's parameter could outlive the function body. To fix it, we just widen the scope to the `function` node. See also gleam-lang/tree-sitter-gleam#25 With respect to the parser: An external scanner has been added that fixes the parsing of strings. Previously, a comment inside a string would act like a comment rather than string contents. See also gleam-lang/tree-sitter-gleam#14 (comment)
Thanks! I’m glad you’re enjoying it and I’m grateful for your patience.
As regards type names, that is technically correct. With respect to constructors, I think those should be mapped to the
I agree it’s pretty loud. Unfortunately, we don’t have any facilities for grammars to direct the manner in which things are highlighted: on our end, it’s basically just a map from highlighting classes to CSS classes (closed-source, unfortunately, though I can give a subject-to-change summary of what is done should you need it). I think it would be cool to allow highlighting grammars to suggest how emphatically or subtly a given class should be highlighted, but that would be a long-term project (as would making the module highlighting a little less punchy, given that we’d have to get input from design, plan for the various colorblindness modes, etc etc). Note that Elixir module names are also highlighted thusly, so at least we’re consistent in our gaudiness. :) If you’d prefer for us to go back to the old highlighting queries, that’s not a problem on our end (though you will notice some marginally longer page load times). |
Oh, I see that the comment-in-string bug is fixed. I can bump that today. |
I forgot to address the property vs argument bit. The TL;DR is
I'm happy to change what highlight is applied to labels and also to differentiate the highlight for data constructor argument labels vs function argument labels if desired (though I'm not especially fond of that idea), but I do believe that labels and the arguments they point to should be able to be highlighted differently. |
With respect to the queries: The locals scope for functions was not large enough, so a function's parameter could outlive the function body. To fix it, we just widen the scope to the `function` node. See also gleam-lang/tree-sitter-gleam#25 With respect to the parser: An external scanner has been added that fixes the parsing of strings. Previously, a comment inside a string would act like a comment rather than string contents. See also gleam-lang/tree-sitter-gleam#14 (comment) A new constructor node has been added as well which makes type highlighting more fine grained. See also gleam-lang/tree-sitter-gleam#29
With respect to the queries: The locals scope for functions was not large enough, so a function's parameter could outlive the function body. To fix it, we just widen the scope to the `function` node. See also gleam-lang/tree-sitter-gleam#25 With respect to the parser: An external scanner has been added that fixes the parsing of strings. Previously, a comment inside a string would act like a comment rather than string contents. See also gleam-lang/tree-sitter-gleam#14 (comment) A new constructor node has been added as well which makes type highlighting more fine grained. See also gleam-lang/tree-sitter-gleam#29
The new highlighting queries have been bumped in production. |
With respect to the queries: The locals scope for functions was not large enough, so a function's parameter could outlive the function body. To fix it, we just widen the scope to the `function` node. See also gleam-lang/tree-sitter-gleam#25 With respect to the parser: An external scanner has been added that fixes the parsing of strings. Previously, a comment inside a string would act like a comment rather than string contents. See also gleam-lang/tree-sitter-gleam#14 (comment) A new constructor node has been added as well which makes type highlighting more fine grained. See also gleam-lang/tree-sitter-gleam#29
With respect to the queries: The locals scope for functions was not large enough, so a function's parameter could outlive the function body. To fix it, we just widen the scope to the `function` node. See also gleam-lang/tree-sitter-gleam#25 With respect to the parser: An external scanner has been added that fixes the parsing of strings. Previously, a comment inside a string would act like a comment rather than string contents. See also gleam-lang/tree-sitter-gleam#14 (comment) A new constructor node has been added as well which makes type highlighting more fine grained. See also gleam-lang/tree-sitter-gleam#29
Hi @patrickt , is there a process for updating the grammar on GitHub? Thank you 🙏 |
https://github.com/github/linguist/tree/master/vendor/grammars I think we may be able to update this here! |
I think the new tree-sitter highlighting/analysis is separate from the linguist configurations and is probably closed-source for now. The grammars in linguist are textmate grammars (regex-based) I believe - for example the Elixir one points at https://github.com/elixir-editors/elixir-tmbundle/blob/b01fffc49179bdec936ca19b53ba4fc7c51a2cc0/Syntaxes/Elixir.tmLanguage although Elixir is highlighted/analyzed with tree-sitter |
Ah boo, I misread and thought they had moved the tree sitters into this repo as well. |
Looks like we may be able to add this to GitHub to get better support for Gleam.
https://twitter.com/importantshock/status/1496884996317011968
Is this something the grammar and queries are ready for?
The text was updated successfully, but these errors were encountered: