- Notifications
You must be signed in to change notification settings - Fork61
Add type, external, let word coloring && unit as constant#85
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Add type, external, let word coloring && unit as constant#85
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Hey thanks! I'll review this later but make sure you've seen#8 (comment) |
Faliszek commentedMar 15, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@chenglou Yep, I saw it and I tried to implement those changes in the smallest way possible, but i have no idea to which scopes we want/should assign those so I went with I will probably need to look into those changes once again, because since I open this PR,@bobzhang was able to shippattern match over modules (which is great)! 🥳 So my PR needs some work. But not sure how we should approach that here (like i said earlier, regexp is not my favorite thing in the world 😄 ). Anyway, any feedback is welcome |
chenglou commentedMar 20, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I don't think However it's a good idea to assign some scope to And yeah this implementation is nice and simple but I think we're missing patterns (each let binding is a pattern too), e.g. As for types, I'm 1. not sure they should be highlighted the same way as values and 2. Either way they're not recursively highlighted here within fields and for annotations like And yeah no worries about the regexes. The problem isn't the regex, it's the archaic TextMate grammar format. ReScript's grammar is complex and we're essentially trying to use regexes and very weak TextMate matching logic here to emulate a full blown parser program. That's why in that thread I advised thinking only in tokenizer and not parser (but even that falls apart because JSX and template literal are that complex). Anyway, just some brain dump. |
It's technically a constant but I think if the parentheses in `f()` and `let f = () => 1` are highlighted but not `f(a)` and `let f = (a) => 1`, then it's confusing. The elegance of `()` being "just" a regular value in ocaml (which isn't even true; it's already a special piece of syntax) doesn't translate well here and nor should we highlight said elegance when the analogy with function parens is stretched that thin.
`_foo` can actually be used as a value, so highlighting it as a comment is very misleading. Imagine seeing that greyed out, removing it, and seeing a type error. We can potentially highlight `_`, because that's genuinely not usable as a value, except we VSCode/textmate doesn't have a good scope for it...
grammars/rescript.tmLanguage.json Outdated
| "include":"#jsx" | ||
| }, | ||
| { | ||
| "include":"#jsx-attributes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
My bad, I tried to also include some jsx highlight - but i just gave up, and forget to remove it 😅
bjornj12 commentedMay 11, 2021
Hi, I will try to look at it in June. But I cant make any promises! 😅 |
TheSpyder commentedMay 26, 2021
This will fix#89 (I guess I didn't search well enough when I logged it) |
Faliszek commentedJun 5, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Now I exactly understand what you meant 😄 My latetest changes:
But I also wanted to improve the rest of coloring, but even If i find matching scope for something, it is supported in one theme, but not in other. So the next ones are kind of a stretch 😅
Results: @chenglou No hurt feelings, if this will be closed and not merged. I see now that creating correct grammar with proper logical text-mate scoping and correctnes of colors in popular themes, is a hell of a task to get it right. But personally I will prefer having not that correct coloring with stupid scopes, than no coloring at all. But I read your reasoning behind it, and I understand you 100%. So if i need to develop with rescript again, i will probably copy my changes and paste it directly to extension grammar :P Feedback welcome |
Faliszek commentedJun 7, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@chenglou Also I am starting to wonder, if dedicated theme for rescript might be a good idea? (for example with two variants dark, and light) I started play with Elixir, and they are also have complicated grammar, and I find elixir specific theme for vscode really delightfulhttps://marketplace.visualstudio.com/items?itemName=Arsen.darcula-theme-for-elixir I am might be able to give it a shoot to create one with your guidance, on what, and how we want to highlight things |
hoichi commentedJul 20, 2021
What about Disclaimer: no idea if TextMate grammar can do it at all. |
TheSpyder commentedOct 26, 2021
@Faliszek would you consider releasing this as a standalone vscode extension? Or would you mind if I did one based on your work? I didn't realise a grammar-only extension was possible, but I just found this A dedicated extension would be easier to use than patching the installed ReScript extension, which iswhat was recommended on the forum. It would also give us a good place to battle-test highlighting ideas before recommending them to the main extension. |
@TheSpyder I mean if other authors of this extension have nothing against fork this extension, feel free to use my changes as you like :) Personally I probably won't find time needed to release and maintain extension in near future. |
TheSpyder commentedOct 26, 2021
My intention is not to fork the whole extension and compete, only to have a way to use your grammar without patching installed extensions. I’ll see what I can cook up this weekend. |
Faliszek commentedMar 17, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@zth yup, I already saw your PR, it looks great! Thank you so much for doing this! You rock :) So I think it's ok to close this one :) |



Uh oh!
There was an error while loading.Please reload this page.
Hi,
First things first. I want to thank you all for your work on this amazing project and this extension.
And now the rest.
Description
One thing that i want to point straight away, I rarely wrote any regexp so sorry in advance if those changes are just garbage 😅
But I look through on files in my project and I think i didn't break any working grammar.
Presented code is mostly from rescript/reason docs, I think i don't miss any possible scenario for using let, external, and type.
What changed
When working with .re files and with vscode-ocaml-platform I have (imo) beatiful syntax highlighting:

and rescript file look like this:
This pr is mostly about 2 changes:
let, type, externalbut alsotype rec, let reckeyword asentity.name.function(the same way vscode-ocaml-platform does it).The word I am matching is
[a-z][a-z_A-Z_0-9_]*- this (i hope) match every valid name for type and let name declaration.NOTE: one small change that I thought would be nice to have is match variable started with
_as comment (line 22 on screens) it looks very cool in my current One Dark Pro theme. (the same way as ocaml-platform)()- (again inspired by vscode-ocaml-platform)In my actual themeOne Dark Pro
Before

After

Dark+
Before:

After:
