language-haskell icon indicating copy to clipboard operation
language-haskell copied to clipboard

Some character literals are not highlighted

Open emlautarom1 opened this issue 3 years ago • 5 comments

Most character literals are highlighted properly, but some - like vowels with tildes - are not.

See the following example:

Screenshot from 2021-03-08 16-23-53

Using Horizon theme, but can reproduce with any theme.

Example characters are as follow (GitHub doesn't highlight characters):

x = ['a', '`', '~', '!', '@']
y = ['¹', 'á', '¶', '«', '»', '¿']

emlautarom1 avatar Mar 08 '21 19:03 emlautarom1

If you or anyone else wants to submit a PR for this go ahead. This should be a reasonably easy fix augmenting the character regex?

JustusAdam avatar Apr 05 '21 10:04 JustusAdam

Any hints on where the regexes are defined? I've never worked on syntax highlighting.

emlautarom1 avatar Apr 05 '21 13:04 emlautarom1

You can try looking at the scopes it is being assigned to. Each rule assigns a, usually descriptively named, "scope" to the thing it matches. For instance a literal 1 will be constant.numeric.floating.decimal.haskell or -> is keyword.operator.arrow.haskell. So if you search for character or char or constant you should find the scope for character literals and it will have a rule attached that contains the regex used for matching. Be careful though, it may be that it is used in multiple places (probably not though).

Maybe one last hint, the tmLanguage file is in the plist format, which basically means its JSON, but in XML format and I'm sure you'll figure out how that works when you look at it :wink:

JustusAdam avatar Apr 06 '21 08:04 JustusAdam

And if you need help with the regex syntax, this is where you can find information (also about how to specify character classes and such) https://macromates.com/manual/en/regular_expressions

JustusAdam avatar Apr 06 '21 08:04 JustusAdam

Wanted to add that the characters § and £ aren't highlighted as well

BiscuitCookies avatar Jan 24 '23 22:01 BiscuitCookies