-
Notifications
You must be signed in to change notification settings - Fork 21
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
Syntax highlighting for multi-line triple-quoted string content #1300
Comments
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.stringsyntaxattribute?view=net-7.0 can be used. Also, it's rather tooling ask, should probably be over dotnet/fsharp. |
Also it's best not to break the interpretation of triple-quoted strings. Instead, we may do this for longer-quoted strings: #1301 let mystr = """""""html
<html>
<body>
<h1>Heading</h1>
<p>Paragraph</p>
</body>
</html>
""""""" |
Is it possible to inject language highlighting into visual studio, easy enough? Here is the VS Extension for html highlighting, but as I sad, highlighting implemented from scratch. But I have no deep knowledge to extend Visual Studio. So maybe I did this wrong! |
There's a VScode extension for a subset of this feature, yes: https://marketplace.visualstudio.com/items?itemName=alfonsogarciacaro.vscode-template-fsharp-highlight Ideally most uses of this feature could be subsumed by tooling recognizing StringSyntaxAttribute - it's already used by the BCL in many places to inject sub-grammars (for example dates and regex). |
FWIW, Rider already works with StringSyntaxAttribute, too (e.g. for regex highlighting). |
We highlight ourselves, by spans (both syntactic and semantic), should be easy enough for us. |
I propose we should have a way to do syntax highlighting (colour coding) of different content inside multi-line triple-quoted string.
Like markdown has: ```json or html and so on:
It might not be optimal to have other content in F# files, typically many times it's better to read separate external file. But also it's a bit over-kill to do file-operations every time. So you might see things like:
or
...and then some 10-50 lines of single colour text without any intellisense or text correction. Hard to find any typos there.
Now, I don't know if this is purely editor thing or language feature: I suspect editors cannot infer content types without the core language change first. A lot of editors use things like compiler service to do things.
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are:
Extra information
I don't know the implementation details, what would be the best way to hint the file content type. Most editors already can do intellisense for basic types like html and json. So maybe something like this:
Affidavit
Please tick these items by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered: