diff --git a/queries/fsharp/rainbow-delimiters.scm b/queries/fsharp/rainbow-delimiters.scm new file mode 100644 index 00000000..96263d0a --- /dev/null +++ b/queries/fsharp/rainbow-delimiters.scm @@ -0,0 +1,98 @@ +; ─── Disabled due to being unable to match more than one argument at a time ─── +; +;(argument_patterns +; ("(" @opening ")" @closing)+ +; ) @container +; +;(record_type_defn +; "{" @opening +; "}" @closing +; ) @container +; +;(type_arguments +; "<" @opening +; ">" @closing +; ) @container +; + +; highlight unit expressions in function applications +; and return types for consistency +(application_expression + (const + (unit + "(" @opening + ")" @closing + )) @container + ) + +(return_expression + (const + (unit + "(" @opening + ")" @closing + )) @container + ) + +(if_expression + (const + (unit + "(" @opening + ")" @closing + )) @container + ) + +(method_or_prop_defn + (const + (unit + "(" @opening + ")" @closing + )) @container + ) + +(function_or_value_defn + body: (const + (unit + "(" @opening + ")" @closing + )) @container + ) + +(paren_expression + "(" @opening + ")" @closing + ) @container + +(paren_pattern + "(" @opening + ")" @closing + ) @container + +(type + "(" @opening + ")" @closing + ) @container + +(type + "<" @opening + ">" @closing + ) @container + + +(list_pattern + "[" @opening + "]" @closing + ) @container + +(array_pattern + "[|" @opening + "|]" @closing + ) @container + +(ce_expression + [ (return_expression (long_identifier_or_op (long_identifier))) + (long_identifier_or_op (long_identifier)) + ] @intermediate + + "{" @opening + "}" @closing + ) @container diff --git a/test/highlight/fsharp/regular.fs b/test/highlight/fsharp/regular.fs new file mode 100644 index 00000000..2650a91f --- /dev/null +++ b/test/highlight/fsharp/regular.fs @@ -0,0 +1,112 @@ +module Regular + +let no_args () = + () + +let one_arg (x: int) = + x + +let two_args (x: int) (y: int) = + x + y + +let three_args (x: int) (y: int) (z: int) = + x + y + z + +let tuple ( (x: (int * float)) ) = + x + +let destructured_tuple ((a, b): int * int) = + a + b + +let array (x: int array) = function + | [|x|] -> x + | [| x; y; z |] -> x + y + x + | _ -> 0 + +let nested_array (x: int array array) = function + | [| [| [| x |] |] |] -> x + | [| [| [| x; y; z |] |] |] -> x + y + z + | _ -> 0 + +let list (x: int list) = function + | [x] -> x + | [ x; y; z ] -> x + y + x + | _ -> 0 + +let nested_list (x: int list list) = function + | [ [ [ x ] ] ] -> x + | [ [ [ x; y; z ] ] ] -> x + y + x + | _ -> 0 + +let return_value = + (Some (Ok (Some (2)))) + +let type_argument (x: seq<'a>) = + x + +let nested_type_argument (x: seq>>) = + x + +type Record = + { a: int + b: string + } + +type Union = + | Tuple of (int * float) + | NestedTuple of (int * (int * (int * int))) + | TypeArgs of Result, float> + +type Wrapper = Wrapper of int * int + +let unwrap (Wrapper (a, b)) = + a + b + +let lambda = + (fun x -> (fun (a, b) -> x)) + +let match_test x = + match x with + | (Some (((((Some (a))))))) -> a + | _ -> 0 + +let unit_args () () () = + () + +let computation_expressions asyncFn (x: int) = + async { + let t = + task { + let a = 2 + let b = 3 + return async { + let! res = asyncFn (x) + return res + a + b + } + } + return t + } + +let if_tests (x: int) = + if x <> 0 then + () + elif x < 1 then + () + else + () + + +type Class(a: int) = + member _.A () = + (a) + + member this.Member () = + () + + static member StaticMember () = + () + +let main _ = + unit_args () ((((((((((())))))))))) (); + one_arg ((((((((((((1)))))))))))) |> ignore; + two_args (1) (((((((((2))))))))) |> ignore;