mirror of
https://github.com/HiPhish/rainbow-delimiters.nvim.git
synced 2024-09-16 14:24:05 +02:00
feat(elm): Add elm queries
This commit is contained in:
parent
a5e8fb4960
commit
9492c13ca9
2 changed files with 114 additions and 0 deletions
63
queries/elm/rainbow-delimiters.scm
Normal file
63
queries/elm/rainbow-delimiters.scm
Normal file
|
@ -0,0 +1,63 @@
|
|||
(exposing_list
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(exposed_operator
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(exposed_union_constructors
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(_
|
||||
"(" @delimiter
|
||||
.
|
||||
(type_expression)
|
||||
.
|
||||
")" @delimiter @sentinel
|
||||
) @container
|
||||
|
||||
(_
|
||||
"(" @delimiter
|
||||
.
|
||||
[(pattern) (union_pattern)]
|
||||
.
|
||||
")" @delimiter @sentinel
|
||||
) @container
|
||||
|
||||
(record_expr
|
||||
"{" @delimiter
|
||||
"}" @delimiter @sentinel) @container
|
||||
|
||||
(record_type
|
||||
"{" @delimiter
|
||||
"}" @delimiter @sentinel) @container
|
||||
|
||||
(record_pattern
|
||||
"{" @delimiter
|
||||
"}" @delimiter @sentinel) @container
|
||||
|
||||
(tuple_expr
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(tuple_type
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(tuple_pattern
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(parenthesized_expr
|
||||
"(" @delimiter
|
||||
")" @delimiter @sentinel) @container
|
||||
|
||||
(list_expr
|
||||
"[" @delimiter
|
||||
"]" @delimiter @sentinel) @container
|
||||
|
||||
(list_pattern
|
||||
"[" @delimiter
|
||||
"]" @delimiter @sentinel) @container
|
51
test/highlight/elm/Regular.elm
Normal file
51
test/highlight/elm/Regular.elm
Normal file
|
@ -0,0 +1,51 @@
|
|||
module Regular exposing (CustomType(..))
|
||||
|
||||
import Browser exposing (UrlRequest(..))
|
||||
import Url.Parser exposing ((</>), (<?>))
|
||||
|
||||
|
||||
type CustomType a
|
||||
= CustomType a
|
||||
|
||||
|
||||
type alias NestedRecordOfCustomType a =
|
||||
{ a : ( Int, List (Maybe ( Int, CustomType a )) )
|
||||
, b : ( Int, { c : CustomType a } )
|
||||
, d : { f : { g : String } }
|
||||
}
|
||||
|
||||
|
||||
nestedTypeExpr : Int -> (Int -> Int) -> (Int -> (Int -> Int))
|
||||
nestedTypeExpr x y =
|
||||
\z -> y
|
||||
|
||||
|
||||
nestedListPatternFunction : List (List ( Int, List ( Int, String ) )) -> List ( String, Int )
|
||||
nestedListPatternFunction list =
|
||||
List.concatMap (\( _, strings ) -> List.map (\( a, b ) -> ( b, a )) strings) (List.concat list)
|
||||
|
||||
|
||||
unwrapCustomType : { b | c : Int } -> CustomType (CustomType { a : Int }) -> Int
|
||||
unwrapCustomType { c } (CustomType (CustomType ({ a } as b))) =
|
||||
(a + (c * 1)) * (a - (a + (b.a * 1)))
|
||||
|
||||
|
||||
patternMatchNestedListOfRecords : List (List (NestedRecordOfCustomType Int)) -> Maybe (List (List (NestedRecordOfCustomType Int)))
|
||||
patternMatchNestedListOfRecords list =
|
||||
case [ list ] of
|
||||
[ [ [ { a, b } ] ] ] ->
|
||||
case ( a, b ) of
|
||||
( ( 1, [ Just ( 1, ct ) ] ), ( 2, { c } ) ) ->
|
||||
Just
|
||||
[ [ { a = ( 1, [ Just ( 1, c ) ] )
|
||||
, b = ( 2, { c = ct } )
|
||||
, d = { f = { g = "test" } }
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
_ ->
|
||||
Nothing
|
Loading…
Reference in a new issue