-
Notifications
You must be signed in to change notification settings - Fork 37
feat: support using directive for scala-cli #237
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
Conversation
Looks great! What do you think @nicolasstucki ? Would it be ok to include this for Scala syntax? |
Hey, awesome stuff @tanishiking! Screen.Recording.2022-07-21.at.13.55.23.movAlthough complete and correct directives are colored as they should, as far as I tested, incomplete ones seem to mess with the coloring of the following lines with regular Scala code (refer to the short clip attached). As in, you may notice that an open quote for the lib dependency string colors the following lines (even though they aren't commented and shouldn't be considered a part of a directive, at any time). Similarly, if the code for the object Hello start a line below the incomplete Still, hyped for the end result, this is promising! |
62016bf
to
31ac9b0
Compare
@Gedochao Hey, thank you for taking a look!
Fixed by changing the - begin: '^\\s*(//>)\\s*(using)\\n+'
+ begin: '^\\s*(//>)\\s*(using)[^\\S\\n]+'
I believe it should be a correct behavior because
|
Something to keep in mind for the future: if scala-cli gets support for path interpolations VirtusLab/scala-cli#1098 they also should get coloured properly |
Just tested, works as a charm 🚀
@tanishiking I see your points, however, for as long as So an open quote for a string like on this screenshot goes against that, coloring stuff that's uncommented. A third opinion may be necessary on this. |
From a technical point of view, if we don't wanna color incomplete double quotation in
|
No idea how to approach it for now, but just one more thought - what's in this PR is already a huge improvement, with syntax coloring for If fixing unclosed quotation within a directive turns out to be a more complex thing, I think it might make sense to extract it to a separate issue and address it separately in the future, while for the time being we push what's already here. |
related to: VirtusLab/scala-cli#1059
This PR adds limited support for the using directive of scala-cli.
Even though the using directives aren't currently a part of the Scala language standard (while there's a PRE-SIP for it, we'd like to have proper syntax highlighting for it.
Based on this change, I'd like to hear some opinions from compiler team :)
Is this
//>
(decided to) becomes a part of scala standard orWhile scala-cli allows us to write various forms of using directives, we focus on one-line, comment-based using directives such as
//> using scala 3.1.3
as it's the most recommended syntax by scala-cli.What we don't support at this moment
using directives without
//>
scala-cli
accepts something likeHowever, according to the discussion in the PRE-SIP, we're leaning towards not introducing the using directives without special comment,
//>
.Therefore, we don't support it in this PR.
multiline using directive
Also, I realized that multiline using directive is also valid
but I would leave it out of scope for now, because it's difficult to capture (even I'm not sure it's possible) with the regex-based TextMate grammar AFAIK. (it would be much easier if we have tokens that represent the start and end of the directive).
/*>using */
We can support it but I just didn't for now, because I'd like to hear people's opinions before going further.
FYI @Gedochao @romanowski @tgodzik Also, it would be good to play around with this build and see how it colorizes the using directives. See the CONTRIBUTING guide for how to build locally https://github.com/scala/vscode-scala-syntax/blob/main/CONTRIBUTING.md
Here's the example
