Skip to content

Commit

Permalink
Overhaul syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
CFiggers committed Oct 5, 2024
1 parent e77566b commit 056971d
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 2 deletions.
21 changes: 19 additions & 2 deletions syntaxes/hy.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
{
"include": "#keysym"
},
{
"include": "#builtin"
},
{
"include": "#symbol"
}
Expand All @@ -47,13 +50,27 @@
"keywords": {
"patterns": [{
"name": "keyword.control.hy",
"match": "\\b(\\.|->|->>|and|match|let|await|annotate|as->|as-model|assert|assoc|break|chainc|comment|cond|continue|do|doc|#doc|([dgls])?for|set[vx]|defclass|defmain|defmacro|defmacro\\/g!|defmacro!|deftag|del|doto|eval-and-compile|eval-when-compile|first|gensym|get|global|if|if\\*|if-not|import|(de)?fn(\\/a)?|last|nonlocal|not(\\?|-in)?|or|print|(quasi)?quote|require|rest|return|cut|raise|try|unless|unpack-iterable|unpack-mapping|unquote|unquote-splice|when|while|with(\\/a)?|with-decorator|with-gensyms|xor|yield(-from)?|butlast|coll\\?|comp|complement|constantly|dec|disassemble|empty\\?|eval|every\\?|exec|float\\?|fraction|even\\?|identity|inc|instance\\?|integer\\?|interleave|interpose|iterable\\?|iterator\\?|juxt|keyword|keyword\\?|macroexpand(-1)?|mangle|merge-with|name|neg\\?|none\\?|nth|numeric\\?|odd\\?|partition|pos\\?|second|some|string\\?|symbol\\?|zero\\?|cycle|distinct|drop|drop-last|drop-while|filter|flatten|iterate|read|read-str|remove|repeat|repeatedly|take|take-nth|take-while|unmangle|False|None|True|as|in|is|py(s)?|lambda|nonlocal|not|pass|abs|all|any|ascii|bin|bool|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr(-register)?|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__|abs|acos|angle|asin|assoc|assq|assv|atan|ceiling|cos|floor|round|sin|sqrt|tan|(?:real|imag)-part|numerator|denominatormodulo|exp|expt|remainder|quotient|lcm|call-with-(?:input|output)-file|(?:close|current)-(?:input|output)-port|with-(?:input|output)-from-file|open-(?:input|output)-file|char-(?:downcase|upcase|ready)|make-(?:polar|promise|rectangular|string|vector)|string(?:-(?:append|copy|length|ref))|vector(?:-length|-ref))[\\s\\)]"
"match": "\\b(and|await|match|let|annotate|assert|break|chainc|cond|continue|deftype|do|except\\*?|finally|else|defreader|([dgls])?for|set[vx]|defclass|defmacro|del|export|eval-and-compile|eval-when-compile|get|global|if|import|(de)?fn|nonlocal|not-in|or|(quasi)?quote|require|return|cut|raise|try|unpack-iterable|unpack-mapping|unquote|unquote-splice|when|while|with|yield|local-macros|in|is|py(s)?|pragma|nonlocal|(is-)?not)[\\s\\)]"
},
{
"name": "keyword.control.dot.hy",
"match": "(?<=\\(\\s*)\\.[\\s\\)]"
}]
},
"builtin": {
"patterns": [{
"name": "storage.builtin.hy",
"match": "\\b(abs|all|any|ascii|bin|breakpoint|callable|chr|compile|delattr|dir|divmod|eval|exec|format|getattr|globals|hasattr|hash|hex|id|input|isinstance|issubclass|iter|aiter|len|locals|max|min|next|anext|oct|ord|pow|print|repr|round|setattr|sorted|sum|vars|False|None|True|NotImplemented|bool|memoryview|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|frozenset|property|int|list|map|object|range|reversed|set|slice|staticmethod|str|super|tuple|type|zip|open|quit|exit|copyright|credits|help)[\\s\\)]"
},
{
"name": "storage.builtin.dots.hy",
"match": "(?<=\\(\\s*)\\.\\.\\.[\\s\\)]"
}]
},
"operators":{
"patterns": [{
"name": "keyword.control.hy",
"match": "(?<=\\()\\s*(\\+=?|\\/+|\\*+|-=?|[!<>]?=|@|%|<<|>>|<|>|&|\\||\\^|~)"
"match": "(?<=\\()\\s*(\\+=?|\\/\\/?=?|\\*\\*?=?|--?=?|[!<>]?=|@=?|%=?|<<?=?|>>?=?|&=?|\\|=?|\\^|~@|~=?|#\\*\\*?)"
}]
},
"strings": {
Expand Down
180 changes: 180 additions & 0 deletions test/hy_symbols.hy
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
; Python Built-ins

(abs)
(all)
(any)
(ascii)
(bin)
(breakpoint)
(callable)
(chr)
(compile)
(delattr)
(dir)
(divmod)
(eval)
(exec)
(format)
(getattr)
(globals)
(hasattr)
(hash)
(hex)
(id)
(input)
(isinstance)
(issubclass)
(iter)
(aiter)
(len)
(locals)
(max)
(min)
(next)
(anext)
(oct)
(ord)
(pow)
(print)
(repr)
(round)
(setattr)
(sorted)
(sum)
(vars)
(None)
(...) (Ellipsis)
(NotImplemented)
(False)
(True)
(bool)
(memoryview)
(bytearray)
(bytes)
(classmethod)
(complex)
(dict)
(enumerate)
(filter)
(float)
(frozenset)
(property)
(int)
(list)
(map)
(object)
(range)
(reversed)
(set)
(slice)
(staticmethod)
(str)
(super)
(tuple)
(type)
(zip)
(open)
(quit)
(exit)
(copyright)
(credits)
(help)

; Hy Macros
(eval-and-compile) (eval_and_compile)
(eval-when-compile) (eval_when_compile)
(do) (do_mac)
(py)
(pys)
(pragma)
(quote)
(quasiquote)
(not)
(~) (bnot)
(and)
(or)
(!=) (hyx_Xexclamation_markXXequals_signX)
(is-not) (is_not)
(in)
(not-in) (not_in)
(=) (hyx_Xequals_signX)
(is)
(<) (hyx_XlessHthan_signX)
(<=) (hyx_XlessHthan_signXXequals_signX)
(>) (hyx_XgreaterHthan_signX)
(>=) (hyx_XgreaterHthan_signXXequals_signX)
(chainc)
(%) (hyx_Xpercent_signX)
(~) (hyx_Xcircumflex_accentX)
(*) (hyx_XasteriskXXasteriskX)
(//) (hyx_XsolidusXXsolidusX)
(<<) (hyx_XlessHthan_signXXlessHthan_signX)
(>>) (hyx_XgreaterHthan_signXXgreaterHthan_signX)
(-=) (hyx_XhyphenHminusX)
(/) (hyx_XsolidusX)
(&) (hyx_XampersandX)
(@) (hyx_Xcommercial_atX)
(+) (hyx_Xplus_signX)
(*) (hyx_XasteriskX)
(|) (hyx_Xvertical_lineX)
(%=) (hyx_Xpercent_signXXequals_signX)
(~=) (hyx_Xcircumflex_accentXXequals_signX)
(+=)(hyx_Xplus_signXXequals_signX)
(/=) (hyx_XsolidusXXequals_signX)
(//=) (hyx_XsolidusXXsolidusXXequals_signX)
(*=) (hyx_XasteriskXXequals_signX)
(--=) (hyx_XhyphenHminusXXequals_signX)
(**=) (hyx_XasteriskXXasteriskXXequals_signX)
(<<=) (hyx_XlessHthan_signXXlessHthan_signXXequals_signX)
(>>=) (hyx_XgreaterHthan_signXXgreaterHthan_signXXequals_signX)
(|=) (hyx_Xvertical_lineXXequals_signX)
(&=) (hyx_XampersandXXequals_signX)
(@=) (hyx_Xcommercial_atXXequals_signX)
(setx)
(setv)
(let)
(annotate)
(deftype)
(global)
(nonlocal)
(del)
(get)
(.) (hyx_Xfull_stopX)
(cut)
(#*) (unpack-iterable)
(if)
(dfor)
(lfor)
(sfor)
(gfor)
(for)
(while)
(break)
(continue)
(with)
(match)
(raise)
(try)
(fn)
(defn)
(defmacro)
(return)
(yield)
(await)
(defclass)
(require)
(import)
(assert)
(unquote)
(~@) (unquote-splice)
(#**) (unpack-mapping)
(except)
(except*) (hyx_exceptXasteriskX)
(finally)
(else)
(cond)
(when)
(defreader)
(get) (get_macro)
(local-macros) (local_macros)
(export)

0 comments on commit 056971d

Please sign in to comment.