mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 17:00:09 -04:00
perf: remove match where possible
This commit is contained in:
parent
654216eb04
commit
85330918f0
37 changed files with 104 additions and 113 deletions
|
|
@ -84,7 +84,7 @@
|
||||||
(#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
|
(#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
|
||||||
|
|
||||||
((word) @boolean
|
((word) @boolean
|
||||||
(#match? @boolean "^(true|false)$"))
|
(#any-of? @boolean "true" "false"))
|
||||||
|
|
||||||
(comment) @comment @spell
|
(comment) @comment @spell
|
||||||
(test_operator) @string
|
(test_operator) @string
|
||||||
|
|
@ -133,4 +133,4 @@
|
||||||
(regex) @string.regex
|
(regex) @string.regex
|
||||||
|
|
||||||
((program . (comment) @preproc)
|
((program . (comment) @preproc)
|
||||||
(#match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
((member_expression
|
((member_expression
|
||||||
object: (identifier) @type.builtin)
|
object: (identifier) @type.builtin)
|
||||||
(#match? @type.builtin "^sys$"))
|
(#eq? @type.builtin "sys"))
|
||||||
|
|
||||||
; Functions
|
; Functions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,28 +59,28 @@
|
||||||
|
|
||||||
; Inline function variables
|
; Inline function variables
|
||||||
((sym_lit) @variable.builtin
|
((sym_lit) @variable.builtin
|
||||||
(#match? @variable.builtin "^[%]"))
|
(#lua-match? @variable.builtin "^%%"))
|
||||||
|
|
||||||
; Constructor
|
; Constructor
|
||||||
((sym_lit) @constructor
|
((sym_lit) @constructor
|
||||||
(#match? @constructor "^-\\>[^\\>].*"))
|
(#lua-match? @constructor "^-\\>[^\\>].*"))
|
||||||
|
|
||||||
; Dynamic variables
|
; Dynamic variables
|
||||||
((sym_lit) @variable.builtin
|
((sym_lit) @variable.builtin
|
||||||
(#match? @variable.builtin "^[*].+[*]$"))
|
(#lua-match? @variable.builtin "^[*].+[*]$"))
|
||||||
|
|
||||||
; Gensym
|
; Gensym
|
||||||
;; Might not be needed
|
;; Might not be needed
|
||||||
((sym_lit) @variable
|
((sym_lit) @variable
|
||||||
(#match? @variable "^.*#$"))
|
(#lua-match? @variable "^.*#$"))
|
||||||
|
|
||||||
; Types
|
; Types
|
||||||
;; TODO: improve?
|
;; TODO: improve?
|
||||||
((sym_lit) @type
|
((sym_lit) @type
|
||||||
(#match? @type "^[A-Z][^/]*$"))
|
(#lua-match? @type "^[%u][^/]*$"))
|
||||||
;; Symbols with `.` but not `/`
|
;; Symbols with `.` but not `/`
|
||||||
((sym_lit) @type
|
((sym_lit) @type
|
||||||
(#match? @type "^[^/]+[.][^/]*$"))
|
(#lua-match? @type "^[^/]+[.][^/]*$"))
|
||||||
|
|
||||||
; Interop
|
; Interop
|
||||||
((sym_lit) @method
|
((sym_lit) @method
|
||||||
|
|
@ -88,11 +88,11 @@
|
||||||
((sym_lit) @field
|
((sym_lit) @field
|
||||||
(#match? @field "^\\.-"))
|
(#match? @field "^\\.-"))
|
||||||
((sym_lit) @field
|
((sym_lit) @field
|
||||||
(#match? @field "^[A-Z].*/.+"))
|
(#lua-match? @field "^[%u].*/.+"))
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
(sym_lit) @method
|
(sym_lit) @method
|
||||||
(#match? @method "^[A-Z].*/.+"))
|
(#lua-match? @method "^[%u].*/.+"))
|
||||||
;; TODO: Special casing for the `.` macro
|
;; TODO: Special casing for the `.` macro
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@
|
||||||
. (argument) @_transform @constant
|
. (argument) @_transform @constant
|
||||||
. (argument) @variable
|
. (argument) @variable
|
||||||
. (argument) @_action @constant
|
. (argument) @_action @constant
|
||||||
(#match? @_transform "TRANSFORM")
|
(#eq? @_transform "TRANSFORM")
|
||||||
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
||||||
)
|
)
|
||||||
(normal_command
|
(normal_command
|
||||||
|
|
@ -169,7 +169,7 @@
|
||||||
. (argument) @variable
|
. (argument) @variable
|
||||||
. (argument) @_action @constant
|
. (argument) @_action @constant
|
||||||
. (argument)? @_selector @constant
|
. (argument)? @_selector @constant
|
||||||
(#match? @_transform "TRANSFORM")
|
(#eq? @_transform "TRANSFORM")
|
||||||
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
||||||
(#any-of? @_selector "AT" "FOR" "REGEX")
|
(#any-of? @_selector "AT" "FOR" "REGEX")
|
||||||
)
|
)
|
||||||
|
|
@ -179,8 +179,8 @@
|
||||||
. (argument) @_transform @constant
|
. (argument) @_transform @constant
|
||||||
(argument) @constant .
|
(argument) @constant .
|
||||||
(argument) @variable
|
(argument) @variable
|
||||||
(#match? @_transform "TRANSFORM")
|
(#eq? @_transform "TRANSFORM")
|
||||||
(#match? @constant "OUTPUT_VARIABLE")
|
(#eq? @constant "OUTPUT_VARIABLE")
|
||||||
)
|
)
|
||||||
|
|
||||||
(escape_sequence) @string.escape
|
(escape_sequence) @string.escape
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
(num_lit) @number
|
(num_lit) @number
|
||||||
|
|
||||||
((sym_lit) @boolean (#match? @boolean "^(t|T)$"))
|
((sym_lit) @boolean (#any-of? @boolean "t" "T"))
|
||||||
|
|
||||||
(nil_lit) @constant.builtin
|
(nil_lit) @constant.builtin
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
|
|
||||||
;; dynamic variables
|
;; dynamic variables
|
||||||
((sym_lit) @variable.builtin
|
((sym_lit) @variable.builtin
|
||||||
(#match? @variable.builtin "^[*].+[*]$"))
|
(#lua-match? @variable.builtin "^[*].+[*]$"))
|
||||||
|
|
||||||
;; quote
|
;; quote
|
||||||
"'" @string.escape
|
"'" @string.escape
|
||||||
|
|
@ -147,7 +147,7 @@
|
||||||
|
|
||||||
;; constant
|
;; constant
|
||||||
((sym_lit) @constant
|
((sym_lit) @constant
|
||||||
(#match? @constant "^[+].+[+]$"))
|
(#lua-match? @constant "^[+].+[+]$"))
|
||||||
|
|
||||||
(var_quoting_lit
|
(var_quoting_lit
|
||||||
marker: "#'" @symbol
|
marker: "#'" @symbol
|
||||||
|
|
@ -180,7 +180,7 @@
|
||||||
|
|
||||||
|
|
||||||
((sym_lit) @symbol
|
((sym_lit) @symbol
|
||||||
(#match? @symbol "^[&]"))
|
(#lua-match? @symbol "^[&]"))
|
||||||
|
|
||||||
[(array_dimension) "#0A" "#0a"] @number
|
[(array_dimension) "#0A" "#0a"] @number
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,14 @@
|
||||||
(sym_lit) @_deftest
|
(sym_lit) @_deftest
|
||||||
.
|
.
|
||||||
(sym_lit) @definition.function
|
(sym_lit) @definition.function
|
||||||
(#match? @_deftest "^(deftest)$")) @scope
|
(#eq? @_deftest "deftest")) @scope
|
||||||
|
|
||||||
(list_lit
|
(list_lit
|
||||||
.
|
.
|
||||||
(sym_lit) @_deftest
|
(sym_lit) @_deftest
|
||||||
.
|
.
|
||||||
(sym_lit) @definition.function
|
(sym_lit) @definition.function
|
||||||
(#match? @_deftest "^(deftest)$")) @scope
|
(#eq? @_deftest "deftest")) @scope
|
||||||
|
|
||||||
(for_clause . (sym_lit) @definition.var)
|
(for_clause . (sym_lit) @definition.var)
|
||||||
(with_clause . (sym_lit) @definition.var)
|
(with_clause . (sym_lit) @definition.var)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
; inherits: c
|
; inherits: c
|
||||||
|
|
||||||
((identifier) @field
|
((identifier) @field
|
||||||
(#match? @field "(^_|^m_|_$)"))
|
(#lua-match? @field "^m?_.*$"))
|
||||||
|
|
||||||
(parameter_declaration
|
(parameter_declaration
|
||||||
declarator: (reference_declarator) @parameter)
|
declarator: (reference_declarator) @parameter)
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
(namespace_identifier) @namespace
|
(namespace_identifier) @namespace
|
||||||
((namespace_identifier) @type
|
((namespace_identifier) @type
|
||||||
(#lua-match? @type "^[A-Z]"))
|
(#lua-match? @type "^[%u]"))
|
||||||
|
|
||||||
(case_statement
|
(case_statement
|
||||||
value: (qualified_identifier (identifier) @constant))
|
value: (qualified_identifier (identifier) @constant))
|
||||||
|
|
@ -135,26 +135,26 @@
|
||||||
((function_declarator
|
((function_declarator
|
||||||
(qualified_identifier
|
(qualified_identifier
|
||||||
(identifier) @constructor))
|
(identifier) @constructor))
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
((call_expression
|
((call_expression
|
||||||
function: (identifier) @constructor)
|
function: (identifier) @constructor)
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
((call_expression
|
((call_expression
|
||||||
function: (qualified_identifier
|
function: (qualified_identifier
|
||||||
name: (identifier) @constructor))
|
name: (identifier) @constructor))
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
((call_expression
|
((call_expression
|
||||||
function: (field_expression
|
function: (field_expression
|
||||||
field: (field_identifier) @constructor))
|
field: (field_identifier) @constructor))
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
;; constructing a type in an initializer list: Constructor (): **SuperType (1)**
|
;; constructing a type in an initializer list: Constructor (): **SuperType (1)**
|
||||||
((field_initializer
|
((field_initializer
|
||||||
(field_identifier) @constructor
|
(field_identifier) @constructor
|
||||||
(argument_list))
|
(argument_list))
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
|
|
||||||
; Constants
|
; Constants
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@
|
||||||
(namespace_name) @namespace
|
(namespace_name) @namespace
|
||||||
|
|
||||||
((property_name) @type.definition
|
((property_name) @type.definition
|
||||||
(#match? @type.definition "^--"))
|
(#lua-match? @type.definition "^[-][-]"))
|
||||||
((plain_value) @type
|
((plain_value) @type
|
||||||
(#match? @type "^--"))
|
(#lua-match? @type "^[-][-]"))
|
||||||
|
|
||||||
[
|
[
|
||||||
(string_value)
|
(string_value)
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
(primitive_type) @type.builtin
|
(primitive_type) @type.builtin
|
||||||
|
|
||||||
((identifier) @type
|
((identifier) @type
|
||||||
(#match? @type "^(#|_#)"))
|
(#lua-match? @type "^_?#"))
|
||||||
|
|
||||||
[
|
[
|
||||||
(slice_type)
|
(slice_type)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
|
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
|
||||||
; specifically identify a node as a function call
|
; specifically identify a node as a function call
|
||||||
(((identifier) @function (#match? @function "^_?[a-z]"))
|
(((identifier) @function (#lua-match? @function "^_?[%l]"))
|
||||||
. (selector . (argument_part))) @function
|
. (selector . (argument_part))) @function
|
||||||
|
|
||||||
; Annotations
|
; Annotations
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
((scoped_identifier
|
((scoped_identifier
|
||||||
scope: (identifier) @type
|
scope: (identifier) @type
|
||||||
name: (identifier) @type)
|
name: (identifier) @type)
|
||||||
(#match? @type "^[a-zA-Z]"))
|
(#lua-match? @type "^[%u%l]"))
|
||||||
|
|
||||||
(type_identifier) @type
|
(type_identifier) @type
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@
|
||||||
(inferred_type) @keyword
|
(inferred_type) @keyword
|
||||||
|
|
||||||
((identifier) @type
|
((identifier) @type
|
||||||
(#match? @type "^_?[A-Z].*[a-z]")) ; catch Classes or IClasses not CLASSES
|
(#lua-match? @type "^_?[%u].*[%l]")) ; catch Classes or IClasses not CLASSES
|
||||||
|
|
||||||
("Function" @type)
|
("Function" @type)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
([
|
([
|
||||||
(let_binding (label) @type)
|
(let_binding (label) @type)
|
||||||
(union_type_entry (label) @type)
|
(union_type_entry (label) @type)
|
||||||
] (#match? @type "^[A-Z]"))
|
] (#lua-match? @type "^%u"))
|
||||||
|
|
||||||
((primitive_expression
|
((primitive_expression
|
||||||
(identifier (label) @type)
|
(identifier (label) @type)
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,3 @@
|
||||||
|
|
||||||
(expose_instruction
|
(expose_instruction
|
||||||
(expose_port) @number)
|
(expose_port) @number)
|
||||||
|
|
||||||
((stopsignal_instruction) @number
|
|
||||||
(#match? @number "[0-9][0-9]?$"))
|
|
||||||
|
|
||||||
((stopsignal_instruction) @constant.builtin
|
|
||||||
(#match? @constant.builtin "SIG(ABRT|HUP|INT|KILL|QUIT|STOP|TERM|TSTP)$"))
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@
|
||||||
|
|
||||||
; Allow different highlighting for specific casings
|
; Allow different highlighting for specific casings
|
||||||
((identifier) @type
|
((identifier) @type
|
||||||
(#match? @type "^[A-Z]"))
|
(#lua-match? @type "^%u"))
|
||||||
|
|
||||||
((identifier) @symbol
|
((identifier) @symbol
|
||||||
(#match? @symbol "^[a-z]"))
|
(#lua-match? @symbol "^%l"))
|
||||||
|
|
||||||
((identifier) @constant
|
((identifier) @constant
|
||||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
(#lua-match? @constant "^%u[%u%d_]+$"))
|
||||||
|
|
||||||
;;; Punctuation ;;;;
|
;;; Punctuation ;;;;
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
(assignment_expression
|
(assignment_expression
|
||||||
left: (member_expression
|
left: (member_expression
|
||||||
property: (property_identifier) @_prop
|
property: (property_identifier) @_prop
|
||||||
(#match? @_prop "(out|inn)erHTML"))
|
(#any-of? @_prop "innerHTML" "outerHTML"))
|
||||||
right: (template_string) @html
|
right: (template_string) @html
|
||||||
(#offset! @html 0 1 0 -1))
|
(#offset! @html 0 1 0 -1))
|
||||||
|
|
||||||
|
|
@ -98,6 +98,6 @@
|
||||||
(assignment_expression
|
(assignment_expression
|
||||||
left: (member_expression
|
left: (member_expression
|
||||||
property: (property_identifier) @_prop
|
property: (property_identifier) @_prop
|
||||||
(#match? @_prop "(out|inn)erHTML"))
|
(#any-of? @_prop "innerHTML" "outerHTML"))
|
||||||
right: (string) @html
|
right: (string) @html
|
||||||
(#offset! @html 0 1 0 -1))
|
(#offset! @html 0 1 0 -1))
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
; Unused Identifiers
|
; Unused Identifiers
|
||||||
((identifier) @comment (#match? @comment "^_"))
|
((identifier) @comment (#lua-match? @comment "^_"))
|
||||||
|
|
||||||
; Comments
|
; Comments
|
||||||
(comment) @comment @spell
|
(comment) @comment @spell
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
(list . (multi_symbol (symbol) @function .))
|
(list . (multi_symbol (symbol) @function .))
|
||||||
|
|
||||||
((symbol) @variable.builtin
|
((symbol) @variable.builtin
|
||||||
(#match? @variable.builtin "^[$]"))
|
(#lua-match? @variable.builtin "^[$]"))
|
||||||
|
|
||||||
(binding) @symbol
|
(binding) @symbol
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@
|
||||||
|
|
||||||
;; match operators of test command
|
;; match operators of test command
|
||||||
(command
|
(command
|
||||||
name: (word) @function.builtin (#match? @function.builtin "^test$")
|
name: (word) @function.builtin (#eq? @function.builtin "test")
|
||||||
argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
||||||
|
|
||||||
;; match operators of [ command
|
;; match operators of [ command
|
||||||
(command
|
(command
|
||||||
name: (word) @punctuation.bracket (#match? @punctuation.bracket "^\\[$")
|
name: (word) @punctuation.bracket (#eq? @punctuation.bracket "[")
|
||||||
argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
@ -106,7 +106,7 @@
|
||||||
|
|
||||||
(command
|
(command
|
||||||
argument: [
|
argument: [
|
||||||
(word) @parameter (#match? @parameter "^-")
|
(word) @parameter (#lua-match? @parameter "^[-]")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@
|
||||||
option: [
|
option: [
|
||||||
(word)
|
(word)
|
||||||
(concatenation (word))
|
(concatenation (word))
|
||||||
] @parameter (#match? @parameter "^-")
|
] @parameter (#lua-match? @parameter "^[-]")
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Strings
|
;; Strings
|
||||||
|
|
@ -160,7 +160,7 @@
|
||||||
(#any-of? @boolean "true" "false"))
|
(#any-of? @boolean "true" "false"))
|
||||||
|
|
||||||
((program . (comment) @preproc)
|
((program . (comment) @preproc)
|
||||||
(#match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
||||||
;; Error
|
;; Error
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,11 @@
|
||||||
directive: (identifier)* @conditional
|
directive: (identifier)* @conditional
|
||||||
argument: (identifier)* @namespace
|
argument: (identifier)* @namespace
|
||||||
)
|
)
|
||||||
(
|
((preproc_call
|
||||||
(preproc_call
|
argument: (identifier)* @namespace) @conditional
|
||||||
argument: (identifier)* @namespace
|
(#eq? @conditional "ifeq"))
|
||||||
) @conditional
|
((preproc_call) @conditional
|
||||||
(#match? @conditional "ifeq")
|
(#any-of? @conditional "else" "endif"))
|
||||||
)
|
|
||||||
(
|
|
||||||
(preproc_call) @conditional
|
|
||||||
(#match? @conditional "(else|endif)")
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Literal numbers and strings
|
;; Literal numbers and strings
|
||||||
(number_literal) @float
|
(number_literal) @float
|
||||||
|
|
@ -64,6 +59,7 @@
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
;; Special identifiers
|
;; Special identifiers
|
||||||
([(identifier) "on" "off" "true" "false" "yes" "no"] @constant.builtin
|
[ "on" "off" "true" "false" "yes" "no" ] @constant.builtin
|
||||||
(#match? @constant.builtin "^(uniform|non-uniform|and|or|on|off|true|false|yes|no)$")
|
|
||||||
)
|
((identifier) @constant.builtin
|
||||||
|
(#any-of? @constant.builtin "uniform" "non-uniform" "and" "or"))
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
(eel_object_path
|
(eel_object_path
|
||||||
(eel_path_identifier) @variable.builtin
|
(eel_path_identifier) @variable.builtin
|
||||||
(#match? @variable.builtin "^(this|props)$")
|
(#any-of? @variable.builtin "this" "props")
|
||||||
)
|
)
|
||||||
|
|
||||||
(eel_object_path
|
(eel_object_path
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
; Tags that start with a lower case letter are HTML tags
|
; Tags that start with a lower case letter are HTML tags
|
||||||
; We'll also use this highlighting for named blocks (which start with `:`)
|
; We'll also use this highlighting for named blocks (which start with `:`)
|
||||||
((tag_name) @tag
|
((tag_name) @tag
|
||||||
(#match? @tag "^(:)?[a-z]"))
|
(#lua-match? @tag "^:?[%l]"))
|
||||||
; Tags that start with a capital letter are Glimmer components
|
; Tags that start with a capital letter are Glimmer components
|
||||||
((tag_name) @constructor
|
((tag_name) @constructor
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
(attribute_name) @property
|
(attribute_name) @property
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
(path_expression (identifier) @variable)
|
(path_expression (identifier) @variable)
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
])
|
])
|
||||||
(#not-match? @variable "yield|outlet|this|else"))
|
(#not-any-of? @variable "yield" "outlet" "this" "else"))
|
||||||
; As are arguments in a block statement
|
; As are arguments in a block statement
|
||||||
(block_statement_start argument: [
|
(block_statement_start argument: [
|
||||||
(path_expression (identifier) @variable)
|
(path_expression (identifier) @variable)
|
||||||
|
|
@ -51,10 +51,10 @@
|
||||||
(path_expression (identifier) @variable)
|
(path_expression (identifier) @variable)
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
])
|
])
|
||||||
(#not-match? @variable "this"))
|
(#not-eq? @variable "this"))
|
||||||
; `this` should be highlighted as a built-in variable
|
; `this` should be highlighted as a built-in variable
|
||||||
((identifier) @variable.builtin
|
((identifier) @variable.builtin
|
||||||
(#lua-match? @variable.builtin "this"))
|
(#eq? @variable.builtin "this"))
|
||||||
|
|
||||||
; If the identifier is just "yield" or "outlet", it's a keyword
|
; If the identifier is just "yield" or "outlet", it's a keyword
|
||||||
((mustache_statement (identifier) @keyword)
|
((mustache_statement (identifier) @keyword)
|
||||||
|
|
@ -65,11 +65,11 @@
|
||||||
(path_expression (identifier) @function)
|
(path_expression (identifier) @function)
|
||||||
(identifier) @function
|
(identifier) @function
|
||||||
])
|
])
|
||||||
(#not-match? @function "if|yield"))
|
(#not-any-of? @function "if" "yield"))
|
||||||
((helper_invocation helper: (identifier) @conditional)
|
((helper_invocation helper: (identifier) @conditional)
|
||||||
(#lua-match? @conditional "if"))
|
(#eq? @conditional "if"))
|
||||||
((helper_invocation helper: (identifier) @keyword)
|
((helper_invocation helper: (identifier) @keyword)
|
||||||
(#lua-match? @keyword "yield"))
|
(#eq? @keyword "yield"))
|
||||||
|
|
||||||
(hash_pair key: (identifier) @property)
|
(hash_pair key: (identifier) @property)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,19 @@
|
||||||
(#match? @_tag "^(h[0-9]|title)$"))
|
(#match? @_tag "^(h[0-9]|title)$"))
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
||||||
(#match? @_tag "^(strong|b)$"))
|
(#any-of? @_tag "strong" "b"))
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
||||||
(#match? @_tag "^(em|i)$"))
|
(#any-of? @_tag "em" "i"))
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
||||||
(#match? @_tag "^(s|del)$"))
|
(#any-of? @_tag "s" "del"))
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
||||||
(#eq? @_tag "u"))
|
(#eq? @_tag "u"))
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
||||||
(#match? @_tag "^(code|kbd)$"))
|
(#any-of? @_tag "code" "kbd"))
|
||||||
|
|
||||||
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
||||||
(#eq? @_tag "a"))
|
(#eq? @_tag "a"))
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
((attribute
|
((attribute
|
||||||
(attribute_name) @_attr
|
(attribute_name) @_attr
|
||||||
(quoted_attribute_value (attribute_value) @text.uri))
|
(quoted_attribute_value (attribute_value) @text.uri))
|
||||||
(#match? @_attr "^(href|src)$"))
|
(#any-of? @_attr "href" "src"))
|
||||||
|
|
||||||
[
|
[
|
||||||
"<"
|
"<"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
(assignment)
|
(assignment)
|
||||||
(const_declaration)
|
(const_declaration)
|
||||||
]
|
]
|
||||||
(#match? @markdown "^\"\"\"")
|
(#lua-match? @markdown "^\"\"\"")
|
||||||
(#offset! @markdown 0 3 0 -3))
|
(#offset! @markdown 0 3 0 -3))
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,8 @@
|
||||||
(application_expression
|
(application_expression
|
||||||
function: (value_path (value_name) @function))
|
function: (value_path (value_name) @function))
|
||||||
|
|
||||||
(
|
((value_name) @function.builtin
|
||||||
(value_name) @function.builtin
|
(#any-of? @function.builtin "raise" "raise_notrace" "failwith" "invalid_arg"))
|
||||||
(#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
|
|
||||||
)
|
|
||||||
|
|
||||||
; Properties
|
; Properties
|
||||||
;-----------
|
;-----------
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
(comments) @spell
|
(comments) @spell
|
||||||
|
|
||||||
((source_file . (comments) @preproc)
|
((source_file . (comments) @preproc)
|
||||||
(#match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
||||||
; POD should be handled specially with its own embedded subtype but for now
|
; POD should be handled specially with its own embedded subtype but for now
|
||||||
; we'll just have to do this.
|
; we'll just have to do this.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
((attribute
|
((attribute
|
||||||
attribute: (identifier) @field)
|
attribute: (identifier) @field)
|
||||||
(#match? @field "^([A-Z])@!.*$"))
|
(#lua-match? @field "^%u@!.*$"))
|
||||||
|
|
||||||
((identifier) @type.builtin
|
((identifier) @type.builtin
|
||||||
(#any-of? @type.builtin
|
(#any-of? @type.builtin
|
||||||
|
|
@ -71,12 +71,12 @@
|
||||||
|
|
||||||
((call
|
((call
|
||||||
function: (identifier) @constructor)
|
function: (identifier) @constructor)
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
((call
|
((call
|
||||||
function: (attribute
|
function: (attribute
|
||||||
attribute: (identifier) @constructor))
|
attribute: (identifier) @constructor))
|
||||||
(#lua-match? @constructor "^[A-Z]"))
|
(#lua-match? @constructor "^%u"))
|
||||||
|
|
||||||
;; Decorators
|
;; Decorators
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@
|
||||||
(comment) @comment @spell
|
(comment) @comment @spell
|
||||||
|
|
||||||
((module . (comment) @preproc)
|
((module . (comment) @preproc)
|
||||||
(#match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
||||||
(string) @string
|
(string) @string
|
||||||
(escape_sequence) @string.escape
|
(escape_sequence) @string.escape
|
||||||
|
|
@ -324,14 +324,14 @@
|
||||||
(expression_statement
|
(expression_statement
|
||||||
(assignment
|
(assignment
|
||||||
left: (identifier) @field))))
|
left: (identifier) @field))))
|
||||||
(#match? @field "^([A-Z])@!.*$"))
|
(#lua-match? @field "^%u@!.*$"))
|
||||||
((class_definition
|
((class_definition
|
||||||
body: (block
|
body: (block
|
||||||
(expression_statement
|
(expression_statement
|
||||||
(assignment
|
(assignment
|
||||||
left: (_
|
left: (_
|
||||||
(identifier) @field)))))
|
(identifier) @field)))))
|
||||||
(#match? @field "^([A-Z])@!.*$"))
|
(#lua-match? @field "^%u@!.*$"))
|
||||||
|
|
||||||
((class_definition
|
((class_definition
|
||||||
(block
|
(block
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
(predefined_type) @type.builtin
|
(predefined_type) @type.builtin
|
||||||
|
|
||||||
((identifier) @type
|
((identifier) @type
|
||||||
(#match? @type "^[A-Z]"))
|
(#lua-match? @type "^%u"))
|
||||||
|
|
||||||
(type_arguments
|
(type_arguments
|
||||||
"<" @punctuation.bracket
|
"<" @punctuation.bracket
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
(comment) @comment @spell
|
(comment) @comment @spell
|
||||||
|
|
||||||
((program . (comment) @preproc)
|
((program . (comment) @preproc)
|
||||||
(#match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
(symbol) @variable
|
(symbol) @variable
|
||||||
|
|
||||||
((symbol) @comment
|
((symbol) @comment
|
||||||
(#match? @comment "^#[cC][iIsS]$"))
|
(#lua-match? @comment "^#[cC][iIsS]$"))
|
||||||
|
|
||||||
;; extension ;;
|
;; extension ;;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,10 @@
|
||||||
(#lua-match? @keyword.return "^return"))
|
(#lua-match? @keyword.return "^return"))
|
||||||
|
|
||||||
((opcode) @conditional
|
((opcode) @conditional
|
||||||
(#match? @conditional "^(if|cmp)"))
|
(#lua-match? @conditional "^if"))
|
||||||
|
|
||||||
|
((opcode) @conditional
|
||||||
|
(#lua-match? @conditional "^cmp"))
|
||||||
|
|
||||||
((opcode) @exception
|
((opcode) @exception
|
||||||
(#lua-match? @exception "^throw"))
|
(#lua-match? @exception "^throw"))
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
((attribute
|
((attribute
|
||||||
attribute: (identifier) @field)
|
attribute: (identifier) @field)
|
||||||
(#match? @field "^([A-Z])@!.*$"))
|
(#lua-match? @field "^%u@!.*$"))
|
||||||
|
|
||||||
((identifier) @type.builtin
|
((identifier) @type.builtin
|
||||||
(#any-of? @type.builtin
|
(#any-of? @type.builtin
|
||||||
|
|
@ -148,7 +148,7 @@
|
||||||
(comment) @comment @spell
|
(comment) @comment @spell
|
||||||
|
|
||||||
((module . (comment) @preproc)
|
((module . (comment) @preproc)
|
||||||
(#match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
||||||
(string) @string
|
(string) @string
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
(#eq? @exception "catch"))
|
(#eq? @exception "catch"))
|
||||||
|
|
||||||
((special_block_keyword) @conditional
|
((special_block_keyword) @conditional
|
||||||
(#match? @conditional "^(if|else)$"))
|
(#any-of? @conditional "if" "else"))
|
||||||
|
|
||||||
[
|
[
|
||||||
"{"
|
"{"
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
(
|
(
|
||||||
(command_expression
|
(command_expression
|
||||||
command: (identifier) @keyword.return)
|
command: (identifier) @keyword.return)
|
||||||
(#match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$")
|
(#lua-match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$")
|
||||||
)
|
)
|
||||||
|
|
||||||
; Subroutine calls
|
; Subroutine calls
|
||||||
|
|
@ -97,14 +97,14 @@
|
||||||
(identifier) @constant)
|
(identifier) @constant)
|
||||||
(
|
(
|
||||||
(argument_list (identifier) @constant.builtin)
|
(argument_list (identifier) @constant.builtin)
|
||||||
(#match? @constant.builtin "^[%/][a-zA-Z][a-zA-Z0-9.]*$")
|
(#lua-match? @constant.builtin "^[%%/][%l%u][%l%u%d.]*$")
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
(command_expression
|
(command_expression
|
||||||
command: (identifier) @keyword
|
command: (identifier) @keyword
|
||||||
arguments: (argument_list . (identifier) @label))
|
arguments: (argument_list . (identifier) @label))
|
||||||
(#match? @keyword "^[gG][oO][tT][oO]$")
|
(#lua-match? @keyword "^[gG][oO][tT][oO]$")
|
||||||
)
|
)
|
||||||
(labeled_expression
|
(labeled_expression
|
||||||
label: (identifier) @label)
|
label: (identifier) @label)
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
; Built-ins {{{
|
; Built-ins {{{
|
||||||
((function_call
|
((function_call
|
||||||
function: (identifier) @function.builtin)
|
function: (identifier) @function.builtin)
|
||||||
(#match? @function.builtin "^(chr|concat|exit|flush|getchar|not|ord|print|print_err|print_int|size|strcmp|streq|substring)$")
|
(#any-of? @function.builtin "chr" "concat" "exit" "flush" "getchar" "not" "ord" "print" "print_err" "print_int" "size" "strcmp" "streq" "substring")
|
||||||
; FIXME: not supported by neovim
|
; FIXME: not supported by neovim
|
||||||
; (#is-not? local)
|
; (#is-not? local)
|
||||||
)
|
)
|
||||||
|
|
||||||
((type_identifier) @type.builtin
|
((type_identifier) @type.builtin
|
||||||
(#match? @type.builtin "^(int|string|Object)$")
|
(#any-of? @type.builtin "int" "string" "Object")
|
||||||
; FIXME: not supported by neovim
|
; FIXME: not supported by neovim
|
||||||
; (#is-not? local)
|
; (#is-not? local)
|
||||||
)
|
)
|
||||||
|
|
||||||
((identifier) @variable.builtin
|
((identifier) @variable.builtin
|
||||||
(#match? @variable.builtin "^self$")
|
(#eq? @variable.builtin "self")
|
||||||
; FIXME: not supported by neovim
|
; FIXME: not supported by neovim
|
||||||
; (#is-not? local)
|
; (#is-not? local)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
(#not-has-parent? @_parent call_expression special_call_expression)))
|
(#not-has-parent? @_parent call_expression special_call_expression)))
|
||||||
|
|
||||||
((identifier) @variable.builtin
|
((identifier) @variable.builtin
|
||||||
(#match? @variable.builtin "^(err|macos|linux|windows)$"))
|
(#any-of? @variable.builtin "err" "macos" "linux" "windows"))
|
||||||
|
|
||||||
(attribute_declaration) @attribute
|
(attribute_declaration) @attribute
|
||||||
;; C: TODO: fixme make `C`.exten highlighted as variable.builtin
|
;; C: TODO: fixme make `C`.exten highlighted as variable.builtin
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@
|
||||||
; highlight constants
|
; highlight constants
|
||||||
(
|
(
|
||||||
(member_access_expression (identifier) @constant)
|
(member_access_expression (identifier) @constant)
|
||||||
(#match? @constant "^[A-Z][A-Z_0-9]*$")
|
(#lua-match? @constant "^[%u][%u%d_]*$")
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
(member_access_expression (member_access_expression) @include (identifier) @constant)
|
(member_access_expression (member_access_expression) @include (identifier) @constant)
|
||||||
(#match? @constant "^[A-Z][A-Z_0-9]*$")
|
(#lua-match? @constant "^[%u][%u%d_]*$")
|
||||||
)
|
)
|
||||||
|
|
||||||
; highlight types and probable types
|
; highlight types and probable types
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
; highlight creation methods in object creation expressions
|
; highlight creation methods in object creation expressions
|
||||||
(
|
(
|
||||||
(object_creation_expression (type (symbol (symbol (symbol)? @include (identifier) @type) (identifier) @constructor)))
|
(object_creation_expression (type (symbol (symbol (symbol)? @include (identifier) @type) (identifier) @constructor)))
|
||||||
(#match? @constructor "^[a-z][a-z_0-9]*$")
|
(#lua-match? @constructor "^[%l][%l%d_]*$")
|
||||||
)
|
)
|
||||||
|
|
||||||
(unqualified_type (symbol . (identifier) @type))
|
(unqualified_type (symbol . (identifier) @type))
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@
|
||||||
|
|
||||||
; Options
|
; Options
|
||||||
((set_value) @number
|
((set_value) @number
|
||||||
(#match? @number "^[0-9]+(\.[0-9]+)?$"))
|
(#lua-match? @number "^[%d]+(%.[%d]+)?$"))
|
||||||
|
|
||||||
(inv_option "!" @operator)
|
(inv_option "!" @operator)
|
||||||
(set_item "?" @operator)
|
(set_item "?" @operator)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ parameter: (IDENTIFIER) @parameter
|
||||||
field_access: (IDENTIFIER)
|
field_access: (IDENTIFIER)
|
||||||
parameter: (IDENTIFIER)
|
parameter: (IDENTIFIER)
|
||||||
] @type
|
] @type
|
||||||
(#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$")
|
(#lua-match? @type "^%u([%l]+[%u%l%d]*)*$")
|
||||||
)
|
)
|
||||||
;; assume camelCase is a function
|
;; assume camelCase is a function
|
||||||
(
|
(
|
||||||
|
|
@ -33,7 +33,7 @@ parameter: (IDENTIFIER) @parameter
|
||||||
field_access: (IDENTIFIER)
|
field_access: (IDENTIFIER)
|
||||||
parameter: (IDENTIFIER)
|
parameter: (IDENTIFIER)
|
||||||
] @function
|
] @function
|
||||||
(#match? @function "^[a-z]+([A-Z][a-z0-9]*)+$")
|
(#lua-match? @function "^%l+([%u][%l%d]*)+$")
|
||||||
)
|
)
|
||||||
|
|
||||||
;; assume all CAPS_1 is a constant
|
;; assume all CAPS_1 is a constant
|
||||||
|
|
@ -42,7 +42,7 @@ parameter: (IDENTIFIER) @parameter
|
||||||
variable_type_function: (IDENTIFIER)
|
variable_type_function: (IDENTIFIER)
|
||||||
field_access: (IDENTIFIER)
|
field_access: (IDENTIFIER)
|
||||||
] @constant
|
] @constant
|
||||||
(#match? @constant "^[A-Z][A-Z_0-9]+$")
|
(#lua-match? @constant "^%u[%u%d_]+$")
|
||||||
)
|
)
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue