Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
204 stars 26 forks source link

Wrong comment character inserted for Shplait / Rhombus. #130

Open TimWhiting opened 1 month ago

TimWhiting commented 1 month ago

Environment

Error message

None

Additional context

When using languages with C style comments (Shplait / Rhombus) the racket extension does not insert the correct comment characters (i.e. // instead of ;).

To reproduce: Install Shplait raco pkg install shplait. Add #lang shplait. Type an expression like 1 + 2. Type Ctrl/Cmd + /, it inserts ; instead of //.

TimWhiting commented 1 month ago

It doesn't look like VSCode supports non-declarative rules for the comment API. Maybe the extension could contribute a second language like rhombus and configure it's declarative features differently? Is that possible with the same extension?

jryans commented 1 month ago

Thanks for reporting the issue! I believe you're correct: I am not currently aware of non-declarative API to set the comment characters. (If anyone knows of a way, please let us know!)

Yes, an extension can contribute multiple languages, so the Rhombus case could be handled... Ideally it could be programmatic, since as we know, Racket allows you to define essentially any language via #lang features.

It probably makes sense to special case Rhombus, even though it's unfortunate that it's necessary to do so.

@TimWhiting, is there any way to identify Shplait files (e.g. by file extension)...? For Rhombus, I believe rhm is common, so we can use that. I wasn't sure about Shplait though.

If there's no extension for Shplait, you could still override VS Code's language detection (per file or per project) to treat Shplait files as Rhombus (once we've added a Rhombus language).

TimWhiting commented 1 month ago

Shplait recommends using the .rhm extension as well. So it should work fine.

jryans commented 3 weeks ago

Adding just the .rhm file extension via an additional language should be pretty simple, mainly a matter of extending this list.

The harder part would be defining a grammar for Rhombus files so that syntax highlighting works correctly as well. Perhaps someone has done that work already...?

I don't anticipate having time to do this work myself in short term, but I am happy to review PRs that contribute this feature.