ionide / ionide-fsgrammar Goto Github PK
View Code? Open in Web Editor NEWShared Textmate Regex Style F# Language Grammar
License: MIT License
Shared Textmate Regex Style F# Language Grammar
License: MIT License
adding a space after }
breaks coloring:
Sample code:
type Company = {
OperatorID : string }
[<RequireQualifiedAccess>]
type Customer =
| Company of Company
/cc @MangelMaxime
After #51 the colorization of the opening brace of computation expressions stopped working. I noticed that today.
With 611f9ce (Before merging #51):
Current master
of this repository and whatever is in Ionide:
This is how it looks like in VS2013:
let zero = async { return 0 }
/cc @MangelMaxime
let private _emitLetBinding (il:ILGenerator, (*methods:MethodSymbolTable, locals:LocalsSymbolTable,*) binding:LetBinding) =
let mutable changeset: Changeset = { methods=Map.empty; locals=Map.empty; }
match binding with
| Literal (varName, Literal.String strLit) ->
let localBuilder = il.DeclareLocal(typeof<string>)
localBuilder.SetLocalSymInfo(varName, 1, 2)
il.Emit(OpCodes.Ldstr, strLit)
il.Emit(OpCodes.Stloc_0)
changeset.locals <- changeset.locals.Add(varName, localBuilder)
| _ -> ()
changeset
open Thoth.Json.Decode
> decodeString string "\"maxime\""
val it : Result<string, string> = Ok "maxime"
> decodeString int "25"
val it : Result<int, string> = Ok 25
> decodeString bool "true"
val it : Result<bool, string> = Ok true
> decodeString float "true"
val it : Result<float, string> = Err "Expecting a float but instead got: true"
I noticed a problem this morning with font ligatures, but I believe after some stack overflow conversations it may be due to the grammer for f# causing issues.
See https://stackoverflow.com/questions/42225024/vscode-font-ligature-issue-whose-issue-is-it for details.
In short, anonymous functions seems to be having a little bit of a problem with detecting the ->
at the end of the declaration. When you put something in the anon function def like parens or the like, it seems to cause the capture scope to break out of the anon function scope and everything seems ok, but if I put just a single variable declaration after fun, it doesnt recognize that its out of the anon function scope until after it sees the -
in he ->
. this seems to cause the engine to both color the -
and >
differently, but it also seems to confused the glyph engine into thinking they should be different characters and not combined into one.
I'll see if I can find a fix, I've submitted a few other pr's for f# syntax not working right, but I'm not very sure how to fix this one yet. If anyone has any thoughts, please let me know.
Currently we treat every function that is followed by { as a builder. The common case that { is a record and not a block is therefore falsely colored.
I hereby propose we move the error to the builder side and use whitelisting. We should whitelist:
A function named "eval" will be highlighted correctly when it's defined. But when you call it, it will be highlighted as if the "val" part of the function is a keyword:
I have also been able to reproduce this behavior with other functions that contain keywords inside their names, like is_a_member
, as long as the "keyword" comes at the end of the name:
Also, if the line is eval (x + 4)
, then the function is highlighted correctly (the val
part is not seen as a keyword). Only when the line looks like eval x
does the highlighting get it wrong. In other words, when it would match a regex that looks like correct use of the val
keyword.
Adding a simple "start-of-word" lookahead to the keyword regex will probably solve this issue.
It would be nice if (** ... *)
comment blocks (and single-line comments with ///
) were internally highlighted as Markdown, because they're most likely FSharp.Formatting comments (either literate .fsx
files or API documentation).
Issues to figure out:
language-markdown
, where the name of the syntax is text.md
. But people might also be using language-gfm
, where the name of the syntax is source.gfm
. And I don't know anything about Visual Studio Code's syntax highlighting; what are the Markdown syntax names there?///
comments, as ugly as that is compared to Markdown syntax.Stumbled on this. Maybe the grammar is the source. At least in VSCode, either of the following lines will break error messages and type checking for the file being processed.
let λ = 1 + 2
let ∑ of numbers should be 💩
= List.sum [1..5]
let whoops = 1 + "abcd"
or
https://github.com/fsharp/fsharp/tree/master/tests/fsharp/core/unicode
...
This is a super edge case, but it's something that can break. All from a silly tweet that said I could use certain Unicode let bindings.
let update _msg model =
model
msg
is colorized but not the underscore.
I am creating this issue to share my current work on the grammar. I am trying to make the regex works for all/most of the possible signatures.
The idea is to find a regex, that can later be re-used if possible. If you think not all the possible signature are covered here please. Please comment with the missing code.
let primitive : int = 0
let tupleOfPrimitives : int * string = 0, ""
let tupleOfPrimitives : (int * string) = 0, ""
let generics : Result<string list, int array> = Ok []
let tupleWithGenerics : Result<string list, int array> * int = Ok [], 0
let tupleWithGenerics2 : (Result<string list, int array> * int) = Ok [], 0
let lambda : int -> unit = ignore
let lambda : (int -> unit) = ignore
let lambda : (int -> unit) -> unit = ignore
let lambda : (Result<string list, int array> -> (string * int)) -> unit = ignore
let lambda : (Result<string list, int array> -> string * int) -> unit = ignore
let inline isLoadingTime<'a> = ""
let printFullName { Firstname = firstname; Surname = surname } : string = firstname + " " + surname
let printFirstName { Firstname = firstname } : string = firstname
let printFirstName ({ Firstname = firstname } : NameRecord) : string = firstname
PS: Yes, I am indeed crazy :D
Take a look at the following picture. In the definition of x1
, the C
case is shown in blue. This is inconsistent with the other examples.
Moved from: ionide/ionide-vscode-fsharp#600
Reported in; ionide/ionide-vscode-fsharp#207
Original comment:
Interesting that they are properly colored in tooltips.
Repro:
create test.fs
, and put the following code inside:
type T = C of int
let m = C 3
let (C n) = C 3
Expected behaviour: the let
keywords should have the same color; m
and n
should have the same color.
ionide-fsharp
2.22.0, reproducible on OS X and Windows 10, VS Code stable and insiders.
This is an issue in other languages also (for example ruby), you can check the discussion in
tonsky/FiraCode#63
and the solution
atom/language-ruby#117
I’m trying to configure keywords to display using bold italic text, because it looks awesome.
Unfortunately it looks like the grammar assigns almost everything to the keyword.other.fsharp
scope including operators, punctuation, the colon in type annotations, every parenthesis (except for unit, weirdly) etc. This doesn’t look as awesome.
Would you be open to splitting these out into things like keyword.operator
, punctuation.separator
, punctuation.section.braces
etc? I can start on this if so. Or is there are good reason why everything is keyword.other.fsharp
?
the ]
is already inserted and when you type the coloring is broken. Please add ]
as stop token in atttribute regex
Moved from ionide/ionide-vscode-fsharp#764
by @hstk
Highlighting / underlining applied to type declarations trails until the =.
Built-in vscode Abyss color theme is sufficient to notice the problem.
Would it be possible to add a license to this project? I assume its MIT like the rest of ionide, just want to make sure though.
I have a value named match'
that I'm performing a pattern match on, and the match
part of the name (not the apostrophe) is colored as a keyword. This is also the case if I name the value e.g. return'
.
Ionide 3.8.0.
Moved from ionide/ionide-vscode-fsharp#603
"Repro:
let foo = @"""\"""
This represents the string "" (including quotes). It looks like Ionide interprets the backslash as escaping the closing quote, and then the subsequent pair of quotes as a second escaped quote, so the full quoted string is never closed. Subsequent lines of code are interpreted by ionide as part of the string.
"
by @simra
Reported in ionide/ionide-vscode-fsharp#457
Original comment:
The colorization for types with attribute Measure is wrong. See screenshot here:
In VSCode, if I use an Unicode symbol (for example an accented character) in a type name, the syntax coloration is broken, as seen below for the type "Evénement":
It may be related to the issue #10
reposted from ionide/ionide-vscode-fsharp#123 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.