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

QuasiQuotes #23

Closed
dpwiz opened this issue May 9, 2017 · 19 comments
Closed

QuasiQuotes #23

dpwiz opened this issue May 9, 2017 · 19 comments

Comments

@dpwiz
Copy link

dpwiz commented May 9, 2017

They can mean just about anything so their contents should be treated either as plain text or a string literal.

There is a list of reserved names for quotes that should remain as Haskell code.

@marcotoniut
Copy link

It would be nice if language-haskell would somehow allow for extended syntax highlighting on QuasiQuote expressions.

@vaclavsvejcar
Copy link

Wondering if there are any plans for this issue? Any chance to have quasiquotes somehow visually distinguished?

@JustusAdam
Copy link
Owner

My intuition is that it is possible, but I don't have the time to work on it. If you want to give it a shot go ahead.

AFAIK there are standard quasi quoters for declarations and expressions. A multi line matcher could be used for the quote brackets and then an include for the expression or declaration rules would add the desired highlighting.

@poscat0x04
Copy link
Contributor

Right now QuasiQuotes are incorrectly linted if there are keywords in it.

@nilehmann
Copy link

Hi, I'm dealing with the same problem. Why is this marked as enhancement and not as bug?

@sheaf
Copy link
Collaborator

sheaf commented May 9, 2020

I've made a simple change so that the entire quasi-quotation is only given the meta.quasi-quotation scope, with no Haskell highlighting.

The "enhancement" part of the bug pertained to the ability to highlight the inside of the quasi-quote depending on the quasi-quoter, e.g. highlight a JSON quasi-quotation using JSON rules, or highlight the different types of Haskell quasi-quotations (type/expression/etc) using the appropriate rules.

@nilehmann
Copy link

@sheaf, that makes sense. And thank you for implementing the quick fix 😃, the highlighting inside of quasiquotes was killing me.

@sheaf
Copy link
Collaborator

sheaf commented May 9, 2020

I also implemented simple Haskell highlighting for the expression, pattern, declaration and type quasi-quoters. Anything more than that starts getting a bit tricky unfortunately.

@nilehmann
Copy link

Should 3.1.0 have these changes? I just updated but I don't see any of the new scopes :S. What could I be doing wrong?

@sheaf
Copy link
Collaborator

sheaf commented May 11, 2020

The changes are indeed part of 3.1.0. (I just checked to confirm).
quasiquote-scopes

If you press Ctrl+Shift+P and bring up Developer: Inspect Editor Tokens and Scopes, you should see the meta.quasi-quotation.haskell scope over the whole quasi quotation, and then the appropriate highlighting in case it's a Haskell quasi-quotation.

@nilehmann
Copy link

Yeah, I was exactly doing that and I didn't see the scope. There's must be something on my end (maybe conflicting with another extension?). I'll try with a clean vscode setup when I have time and see...

@sheaf
Copy link
Collaborator

sheaf commented May 11, 2020

The other thing you can try is to manually revert to an older extension (Install another version... after pressing the settings gear next to the extension in the list of extensions), and then update again to 3.1.0.

@JustusAdam
Copy link
Owner

Ah that's my fault. Apparently I forgot to rebuild the JSON before publishing. I really need to make that automatic.

@nilehmann
Copy link

nilehmann commented May 11, 2020

Yup, working for me in 3.2.0 now. On the bright side I learned a lot about scopes, textmate and stuffs along the way 😁

@JustusAdam
Copy link
Owner

Run while you still can 😝 😆

@jbpotonnier
Copy link

jbpotonnier commented Oct 16, 2020

Would it be possible to mark the quasi quote content with the scope meta.embedded.block.{nameOfQuasiQuote} ?

For example, the content of

[hsx|
        <div>
        ...
        </div>
    |]

would be marked as meta.embedded.block.hsx

If I got it correctly, it would then be possible to provide separate extensions for any quasiquote syntax.

@sheaf
Copy link
Collaborator

sheaf commented Oct 16, 2020

@jbpotonnier Thanks for the suggestion, which I've implemented in 4c9905e. So we have:

[hsx| ... |]
      ^^^ meta.embedded.block.hsx

[Qualifier.hsx| ... |]
                ^^^ meta.embedded.block.hsx

Let me know if that works for you.

@poscat0x04
Copy link
Contributor

poscat0x04 commented Dec 9, 2020

Currently (version 3.3.0), quasi-quotations will break the linting of the code after it if there are no letters in between the parenthesis:
image
image

@sheaf
Copy link
Collaborator

sheaf commented Feb 4, 2021

@poscat0x04 Fixed the issue with empty quasi-quotations in 150c9c5, thanks for the bug report.

@sheaf sheaf closed this as completed Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants