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

feat(languages): update just grammar and queries #11306

Merged
merged 2 commits into from
Jul 28, 2024

Conversation

RoloEdits
Copy link
Contributor

Updates the queries and grammar for just. This includes support for shebang syntax highlighting in the commands.

Part of this pr also includes a change in how language_configuration_for_injection_string works, with instructions from @the-mikedavis.

Supersedes: #9850
Fixes: #8226

@RoloEdits
Copy link
Contributor Author

In trying to make sure the shebang injections worked properly I went through an added some from languages.toml that had a shebang, but got some weird results.

image

The syntax highlighting for the actual language seems correct? But the way the shebang is not greyed out the same for all of them is odd. I though it might have something to do with the comment-token, but nushells is also a #. Not sure if the is an issue here with the injection queries or there is an underlying issue at play.

@poliorcetics
Copy link
Contributor

poliorcetics commented Jul 24, 2024

I have questions because the tree-sitter-just grammar helix uses is quite wonky around triple quoted strings and interpolations, so does the following highlight correctly now:

a := """a string with a " inside"""

b := '''a string with a ' inside'''

c := ```a string with a ` inside```

recipe1:
    echo "{{ a + b }}" {{ c }}

recipe2:
    #!/usr/bin/env bash
    echo "{{ a + b }}" {{ c }}
    if [[ {{ a }} != "string" ]]; then echo "{{ b }}" '{{ c }}'; fi

@RoloEdits
Copy link
Contributor Author

With the double quotes commented out it looks like this:
image

With them active:
image

@poliorcetics
Copy link
Contributor

poliorcetics commented Jul 25, 2024

It's sad the {{ aren't highlighted in recipes, since they're just syntax and not the syntax of the language inside the recipe, but I think that's a tree sitter limitation

I suppose the following also fails:

recipe:
    echo {{ shell("abc", "def") }}

Another thing I found while testing the current grammar and queries:

a := "a"
b := "b"
c := a / b # Highlighting  below changes if the `/` is replaced by a `+`

r:
 echo {{ a }} {{ b }}

Another one:

[private]
r: dep

[private] # The last `]` is not highlighted correctly currently
r: dep

@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Jul 25, 2024
@RoloEdits
Copy link
Contributor Author

Look like some of these should be fixed with the new changes? Need to see if I can fix the triple quoting and then going to need some help with the the shebang highlighting not working as it seems its outside of just the grammar/query files?

image

@poliorcetics
Copy link
Contributor

poliorcetics commented Jul 25, 2024

I have made my own tree sitter grammar to work around most of these issues in the past: https://github.com/poliorcetics/tree-sitter-just, I cleaned it up recently and notably strings with """ are properly supported here https://github.com/poliorcetics/tree-sitter-just/blob/main/grammar.js#L211

The only thing is doesn't support is shebang parsing, that's my next plan Done!

@RoloEdits
Copy link
Contributor Author

@poliorcetics if you want, it might be easier if you made your own pr for the grammar/queries using your tree-sitter. Just remember to put a license for it. And you will need to the fix for the shebang from 8e05c35

@poliorcetics
Copy link
Contributor

Not yet, mostly because the grammar is not complete yet! I would be very glad to have an helix with the improvements you made already 👍

@the-mikedavis
Copy link
Member

the-mikedavis commented Jul 28, 2024

This will also fix injection for some Nix cases. For example:

{
  foo = ''
    #!/bin/sh
    echo -n "Hello, world!"
  '';
}

on master doesn't highlight the shell at all, it's just a string

@pascalkuthe pascalkuthe merged commit 6eae846 into helix-editor:master Jul 28, 2024
6 checks passed
@RoloEdits RoloEdits deleted the just-grammer branch July 28, 2024 17:05
@poliorcetics
Copy link
Contributor

Hello @RoloEdits, made the MR in #11380 :)

SofusA pushed a commit to SofusA/helix-pull-diagnostics that referenced this pull request Aug 4, 2024
* feat(languages): update `just` grammar and queries

Bump the

* refactor(syntax): inject shebang by id not name

---------

Co-authored-by: Trevor Gross <[email protected]>
mxxntype pushed a commit to mxxntype/helix that referenced this pull request Aug 14, 2024
* feat(languages): update `just` grammar and queries

Bump the

* refactor(syntax): inject shebang by id not name

---------

Co-authored-by: Trevor Gross <[email protected]>
kyruzic pushed a commit to kyruzic/helix that referenced this pull request Sep 27, 2024
* feat(languages): update `just` grammar and queries

Bump the

* refactor(syntax): inject shebang by id not name

---------

Co-authored-by: Trevor Gross <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

newline at eof in justfile creates livelock
5 participants