Skip to content

Commit

Permalink
feat(highlights): add more built-in functions for ecma, rust and …
Browse files Browse the repository at this point in the history
…`haskell` (#12488)

Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com>
  • Loading branch information
nik-rev and nik-rev authored Jan 11, 2025
1 parent e440e54 commit a539199
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 2 deletions.
27 changes: 25 additions & 2 deletions runtime/queries/ecma/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,31 @@
(#match? @variable.builtin "^(arguments|module|console|window|document)$")
(#is-not? local))

((identifier) @function.builtin
(#eq? @function.builtin "require")
(call_expression
(identifier) @function.builtin
(#any-of? @function.builtin
"eval"
"fetch"
"isFinite"
"isNaN"
"parseFloat"
"parseInt"
"decodeURI"
"decodeURIComponent"
"encodeURI"
"encodeURIComponent"
"require"
"alert"
"prompt"
"btoa"
"atob"
"confirm"
"structuredClone"
"setTimeout"
"clearTimeout"
"setInterval"
"clearInterval"
"queueMicrotask")
(#is-not? local))

; Function and method definitions
Expand Down
249 changes: 249 additions & 0 deletions runtime/queries/haskell/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,255 @@
(char) @constant.character
(string) @string

(exp_apply
(exp_name
(variable) @function.builtin
(#any-of? @function.builtin
; built in functions from the Haskell prelude (https://hackage.haskell.org/package/base-4.21.0.0/docs/Prelude.html)
; basic data types
"not"
"maybe"
"either"

; tuples
"fst"
"snd"
"curry"
"uncurry"

; Ord
"compare"
"min"
"max"

; Enum
"succ"
"pred"
"toEnum"
"fromEnum"
"enumFrom"
"enumFromThen"
"enumFromThenTo"

; Num
"negate"
"abs"
"signum"
"fromInteger"

; Real
"toRational"

; Integral
"quot"
"rem"
"div"
"mod"
"quotRem"
"divMod"
"toInteger"

; Fractional
"recip"
"fromRational"

; Floating
"exp"
"log"
"sqrt"
"logBase"
"sin"
"cos"
"tan"
"asin"
"acos"
"atan"
"sinh"
"cosh"
"tanh"
"asinh"
"acosh"
"atanh"

; RealFrac
"properFraction"
"truncate"
"round"
"ceiling"
"floor"

; RealFloat
"floatRadix"
"floatDigits"
"floatRange"
"decodeFloat"
"encodeFloat"
"exponent"
"significand"
"scaleFloat"
"isNaN"
"isInfinite"
"isDenormalized"
"isNegativeZero"
"isIEEE"
"atan2"

; Numeric functions
"subtract"
"even"
"odd"
"gcd"
"lcm"
"fromIntegral"
"realToFrac"

; Monoid
"mempty"
"mconcat"
"mappend"

; Functor
"fmap"

; Applicative
"liftA2"
"pure"

; Monad
"return"

; MonadFail
"fail"
"mapM_"
"sequence_"

; Foldable
"foldMap"
"foldr"
"foldl"
"foldl'"
"foldr1"
"foldl1"
"elem"
"maximum"
"minimum"
"sum"
"product"

; Traversable
"traverse"
"sequenceA"
"mapM"
"sequence"

; miscellaneous
"id"
"const"
"flip"
"until"
"asTypeOf"
"error"
"errorWithoutStackTrace"
"undefined"

; List
"map"
"filter"
"head"
"last"
"tail"
"init"
"null"
"length"
"reverse"

; Foldable
"and"
"or"
"any"
"all"
"concat"
"concatMap"

; Building lists
"scanl"
"scanl1"
"scanr"
"scanr1"

; Infinite lists
"iterate"
"repeat"
"replicate"
"cycle"

; Sublists
"take"
"drop"
"takeWhile"
"dropWhile"
"span"
"break"
"splitAt"

; Searching lists
"notElem"
"lookup"

; zipping and unzipping
"zip"
"zip3"
"zipWith"
"zipWith3"
"unzip"
"unzip3"

; String
"lines"
"words"
"unlines"
"unwords"

; Converting to String
"show"
"showList"
"shows"
"showChar"
"showString"
"showParen"

; Converting from String
"readsPrec"
"readList"
"reads"
"readParen"
"read"
"lex"

; Input and output
"putChar"
"putStr"
"putStrLn"
"print"
"getChar"
"getLine"
"getContents"
"interact"

; Files
"readFile"
"writeFile"
"appendFile"
"readIO"
"readLn"

; Exception handling
"ioError"
"userError")
)
)


(con_unit) @constant.builtin ; unit, as in ()

(comment) @comment
Expand Down
8 changes: 8 additions & 0 deletions runtime/queries/rust/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
(#any-of? @type.enum.variant.builtin "Some" "None" "Ok" "Err"))


(call_expression
(identifier) @function.builtin
(#any-of? @function.builtin
"drop"
"size_of"
"size_of_val"
"align_of"
"align_of_val"))

((type_identifier) @type.builtin
(#any-of?
Expand Down

0 comments on commit a539199

Please sign in to comment.