Code Monkey home page Code Monkey logo

ionide-fsgrammar's People

Contributors

am11 avatar booksbaum avatar brianrourkeboll avatar cloudroutine avatar colinbull avatar dawedawe avatar dbrattli avatar eloraiby avatar forki avatar gdziadkiewicz avatar inosik avatar jkillingsworth avatar jl0pd avatar josselinauguste avatar krzysztof-cieslak avatar mangelmaxime avatar mbottini avatar nhirschey avatar rmunn avatar rzhao271 avatar samueleaton avatar selketjah avatar sillyotter avatar slang25 avatar vain0x avatar vasily-kirichenko avatar vbfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionide-fsgrammar's Issues

Function named "eval" incorrectly highlighted

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:

incorrent-highlighting

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:

incorrent-highlighting-2

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.

type colorization wrong when adding comment after }

image

Remark: this also happens if you just have whitespaces after the }, but intentional or not, I actually like that ;)

image


Syntax Colorization Failure

type One =
    { Id : string }

type Two =
    { Id : int } //test

type Three =
    { Id : int }

System Details

  • OS: Windows
  • VSCode
  • Installed Extension Version: v3.22.3

Parse (** ... *) and /// comments as Markdown

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:

  • What is the name of the Markdown syntax that most people will have? AFAIK the most popular one for Atom is 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?
  • Should this be an option that people can turn on and off? (Is that even possible in a syntax grammar?) Some people might use XML in /// comments, as ugly as that is compared to Markdown syntax.

License

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.

Incorrect signature for `val` declaration

Preview

image

Code

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"

Make a pass to choose the symbol color

We are still missing some grammar part and I am working on it.

After adding them, we should do a pass over the symbols and choose what is a symbol or not and their color.

Example {, =, : etc. are colored in purple:

capture d ecran 2018-05-29 a 16 08 41

capture d ecran 2018-05-29 a 16 08 49

When (, ,, ? aren't:

capture d ecran 2018-05-29 a 16 05 17

Anon function issue

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.

image

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.

System Details

  • Windows 10
  • VSCode 1.9.1
  • ionide 2.22.2

Inconsistent syntax highlighting: destructuring let

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.

Actual behavior:
image

ionide-fsharp 2.22.0, reproducible on OS X and Windows 10, VS Code stable and insiders.

Paket.dependencies grammar

image

github should be only colorized if it's on begging of line (type of dependency)
git should be colorized if it's on begging of line (type of dependency)

#if #endif coloration

screen shot 2018-07-16 at 21 08 58


Syntax Colorization Failure

    Program.mkProgram init update
    #if DEBUG
    |> Program.withConsoleTrace
    #endif
    |> Program.run

System Details

  • OS: mac OS High Sierra version 10.13.5
  • VSCode 1.25.1
  • Installed Extension Version: 3.22.3

Braces of CEs are colored differently

After #51 the colorization of the opening brace of computation expressions stopped working. I noticed that today.

With 611f9ce (Before merging #51):

Screenshot: Brace is colored

Current master of this repository and whatever is in Ionide:

Screenshot: Brace isn't colored

This is how it looks like in VS2013:

Screenshot: VS2013

Syntax Colorization Failure

let zero = async { return 0 }

/cc @MangelMaxime

Backslashes mixed with quotes in @-escaped strings break syntax highlighting

"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

Unicode characters in let bindings can break intellisence & errors

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"

Also see:
https://github.com/fsharp/fsharp/blob/master/tests/xplat/core/FsharpUnitTestProject/SharedTests/unicode.fs

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.

Try to support all the different signature

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.

Preview

capture d ecran 2018-07-17 a 15 24 36

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

'of' inside identifier is marked as keyword

Syntax Colorization Failure

ionide-color-bug

// Wrong colorization of 'of'
let aofb = ()
aofb
let ofb = ()
ofb
let aof = ()
aof

// Expected colorization
let bla = ()
bla

System Details

  • OS: Windows 10
  • VSCode 1.23.1
  • Installed Extension: Ionide-fsharp 3.21.0

Comment style isn't applied in parameter list

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

screen shot 2017-02-11 at 7 57 08 am

Better keyword scope selectivity

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.

screen shot

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?

Change builder detection to whitelisting

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:

  • async
  • promise
  • task
  • maybe
  • asyncMaybe
  • all Saturn builders like controller

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.