JustusAdam / language-haskell

Highlighting support for the Haskell language in visual studio code.
https://marketplace.visualstudio.com/items/justusadam.language-haskell
BSD 3-Clause "New" or "Revised" License
96 stars 48 forks source link

Add some examples how to configure QuasiQuotation syntax highlighting? #185

Open vaclavsvejcar opened 3 years ago

vaclavsvejcar commented 3 years ago

First of all, I'm sorry if this is too much unrelated to language-haskell itself, but I was wondering if you could provide some examples (or at least links to some external documentation) how exactly can I configure the newly added logic that allows syntax highlighting for quasiquotes? Why I'm asking for this - I'm really happy with this VSCode extension, but I have zero experience how it works under the hood. I can imagine that most of people would use this highlighting stuff to some common use-cases, such as to highlight quasiquotations used to build regular expressions or string interpolators, such as:

let regex = [re|^\h*-}|\w+\h*-}|^--|]
let interpolated = [i|Hello, #{userName user}|]

I have no idea how much work is to configure the syntax highlighting for this, but maybe it would be worth it to more promote this feature in documentation with few examples?

vaclavsvejcar commented 3 years ago

@JustusAdam could you please give some hints how to do this? After that I'm happy to make PR with adding the documentation somewhere, if you're interested (e.g. README.md).

JustusAdam commented 3 years ago

Hey Thanks for the feedback.

Unfortunately this is not a feature I implemented or dug into a lot. But the way I see it there is a meta.embedded.block.{quasi-quoter} scope that gets assigned to the quoter. I think you then need to define how that is highlighted with an embedding like this one here we use for markdown.