mirror of
https://github.com/elladunbar/tree-sitter-hy.git
synced 2025-11-05 14:59:55 -06:00
Vastly improve highlighting
This commit is contained in:
parent
66026fe74b
commit
ed44ef8755
1 changed files with 151 additions and 37 deletions
|
|
@ -4,7 +4,16 @@
|
||||||
(immediate_symbol)
|
(immediate_symbol)
|
||||||
] @variable
|
] @variable
|
||||||
|
|
||||||
(keyword) @property
|
(keyword
|
||||||
|
(immediate_symbol) @variable.parameter)
|
||||||
|
|
||||||
|
(dotted_identifier
|
||||||
|
[
|
||||||
|
(symbol) @variable.member
|
||||||
|
(immediate_symbol) @variable.member
|
||||||
|
(_)
|
||||||
|
_
|
||||||
|
]+)
|
||||||
|
|
||||||
; Symbol naming conventions
|
; Symbol naming conventions
|
||||||
([
|
([
|
||||||
|
|
@ -43,22 +52,53 @@
|
||||||
(dotted_identifier) @function.method.call)
|
(dotted_identifier) @function.method.call)
|
||||||
|
|
||||||
;Function definitions
|
;Function definitions
|
||||||
(expression
|
(function
|
||||||
.
|
"defn" @keyword.function
|
||||||
(symbol) @keyword.function
|
"async"? @keyword.function
|
||||||
(symbol) @function
|
decorators: (variable_list
|
||||||
.
|
[
|
||||||
(list
|
(symbol)
|
||||||
(symbol)* @parameter)
|
(dotted_identifier)
|
||||||
(#any-of? @keyword.function "defn" "defmacro"))
|
]+ @attribute)?
|
||||||
|
(type_parameters
|
||||||
|
"tp" @property
|
||||||
|
[
|
||||||
|
(symbol)
|
||||||
|
(dotted_identifier)
|
||||||
|
]+ @type)?
|
||||||
|
(type_annotation
|
||||||
|
type: (_) @type)?
|
||||||
|
name: (symbol) @function
|
||||||
|
(parameter_list
|
||||||
|
[
|
||||||
|
(symbol)* @variable.parameter
|
||||||
|
(_)*
|
||||||
|
_*
|
||||||
|
]*))
|
||||||
|
|
||||||
(expression
|
(lambda
|
||||||
.
|
"fn" @keyword.function
|
||||||
(symbol) @keyword.function
|
"async"? @keyword.function
|
||||||
.
|
(parameter_list
|
||||||
(list
|
[
|
||||||
(symbol)* @parameter)
|
(symbol)* @variable.parameter
|
||||||
(#any-of? @keyword.function "fn" "defreader"))
|
(_)*
|
||||||
|
_*
|
||||||
|
]*))
|
||||||
|
|
||||||
|
(macro
|
||||||
|
"defmacro" @keyword.function
|
||||||
|
name: (symbol) @function
|
||||||
|
(parameter_list
|
||||||
|
[
|
||||||
|
(symbol)* @variable.parameter
|
||||||
|
(_)*
|
||||||
|
_*
|
||||||
|
]*))
|
||||||
|
|
||||||
|
(reader
|
||||||
|
"defreader" @keyword.function
|
||||||
|
name: (symbol) @function)
|
||||||
|
|
||||||
; Literals
|
; Literals
|
||||||
((symbol) @constant.builtin
|
((symbol) @constant.builtin
|
||||||
|
|
@ -104,19 +144,77 @@
|
||||||
((symbol) @keyword.return
|
((symbol) @keyword.return
|
||||||
(#any-of? @keyword.return "return" "yield"))
|
(#any-of? @keyword.return "return" "yield"))
|
||||||
|
|
||||||
(expression
|
(import
|
||||||
.
|
"import" @keyword.import
|
||||||
(symbol) @keyword.import
|
|
||||||
.
|
|
||||||
[
|
[
|
||||||
(symbol)
|
(module_import
|
||||||
(dotted_identifier)
|
[
|
||||||
] @module
|
(symbol) @module
|
||||||
((keyword) @keyword
|
(dotted_identifier) @module
|
||||||
.
|
(aliased_import
|
||||||
(symbol) @module
|
[
|
||||||
(#eq? @keyword ":as"))?
|
(symbol) @module
|
||||||
(#any-of? @keyword.import "import" "require"))
|
(dotted_identifier) @module
|
||||||
|
]
|
||||||
|
"as" @keyword.import
|
||||||
|
(symbol) @module)
|
||||||
|
]*)
|
||||||
|
(named_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
(aliased_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
]
|
||||||
|
"as" @keyword.import
|
||||||
|
(symbol) @module)
|
||||||
|
]*)
|
||||||
|
]*)
|
||||||
|
|
||||||
|
(require
|
||||||
|
"require" @keyword.import
|
||||||
|
[
|
||||||
|
(module_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
(aliased_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
]
|
||||||
|
"as" @keyword.import
|
||||||
|
(symbol) @module)
|
||||||
|
]*)
|
||||||
|
(named_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
(aliased_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
]
|
||||||
|
"as" @keyword.import
|
||||||
|
(symbol) @module)
|
||||||
|
]*)
|
||||||
|
(namespace_require
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
"macros" @keyword.import
|
||||||
|
"readers" @keyword.import
|
||||||
|
(aliased_import
|
||||||
|
[
|
||||||
|
(symbol) @module
|
||||||
|
(dotted_identifier) @module
|
||||||
|
]
|
||||||
|
"as" @keyword.import
|
||||||
|
(symbol) @module)
|
||||||
|
]*)
|
||||||
|
]*)
|
||||||
|
|
||||||
((symbol) @keyword.conditional
|
((symbol) @keyword.conditional
|
||||||
(#any-of? @keyword.conditional "if" "when" "cond" "else" "match" "chainc"))
|
(#any-of? @keyword.conditional "if" "when" "cond" "else" "match" "chainc"))
|
||||||
|
|
@ -128,12 +226,25 @@
|
||||||
(#any-of? @keyword.exception "raise" "try"))
|
(#any-of? @keyword.exception "raise" "try"))
|
||||||
|
|
||||||
; Classes
|
; Classes
|
||||||
(expression
|
(class
|
||||||
.
|
"defclass" @keyword.type
|
||||||
(symbol) @keyword.type
|
decorators: (variable_list
|
||||||
.
|
[
|
||||||
(symbol) @type
|
(symbol)
|
||||||
(#eq? @keyword.type "defclass"))
|
(dotted_identifier)
|
||||||
|
]+ @attribute)?
|
||||||
|
(type_parameters
|
||||||
|
"tp" @property
|
||||||
|
[
|
||||||
|
(symbol)
|
||||||
|
(dotted_identifier)
|
||||||
|
]+ @type)?
|
||||||
|
name: (symbol) @type
|
||||||
|
superclasses: (variable_list
|
||||||
|
[
|
||||||
|
(symbol)
|
||||||
|
(dotted_identifier)
|
||||||
|
]+ @type)?)
|
||||||
|
|
||||||
((symbol) @variable.builtin
|
((symbol) @variable.builtin
|
||||||
(#eq? @variable.builtin "self"))
|
(#eq? @variable.builtin "self"))
|
||||||
|
|
@ -141,10 +252,12 @@
|
||||||
(expression
|
(expression
|
||||||
.
|
.
|
||||||
(symbol) @_dot
|
(symbol) @_dot
|
||||||
.
|
[
|
||||||
(_)
|
_
|
||||||
.
|
(_)
|
||||||
|
]+
|
||||||
(symbol) @variable.member
|
(symbol) @variable.member
|
||||||
|
.
|
||||||
(#eq? @_dot "."))
|
(#eq? @_dot "."))
|
||||||
|
|
||||||
; Builtin functions
|
; Builtin functions
|
||||||
|
|
@ -194,6 +307,7 @@
|
||||||
"~@"
|
"~@"
|
||||||
"#*"
|
"#*"
|
||||||
"#**"
|
"#**"
|
||||||
|
"#^"
|
||||||
] @function.macro
|
] @function.macro
|
||||||
|
|
||||||
(dotted_identifier
|
(dotted_identifier
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue