mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -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]))?)$"))
|
||||
|
||||
((word) @boolean
|
||||
(#match? @boolean "^(true|false)$"))
|
||||
(#any-of? @boolean "true" "false"))
|
||||
|
||||
(comment) @comment @spell
|
||||
(test_operator) @string
|
||||
|
|
@ -133,4 +133,4 @@
|
|||
(regex) @string.regex
|
||||
|
||||
((program . (comment) @preproc)
|
||||
(#match? @preproc "^#!/"))
|
||||
(#lua-match? @preproc "^#!/"))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
((member_expression
|
||||
object: (identifier) @type.builtin)
|
||||
(#match? @type.builtin "^sys$"))
|
||||
(#eq? @type.builtin "sys"))
|
||||
|
||||
; Functions
|
||||
|
||||
|
|
|
|||
|
|
@ -59,28 +59,28 @@
|
|||
|
||||
; Inline function variables
|
||||
((sym_lit) @variable.builtin
|
||||
(#match? @variable.builtin "^[%]"))
|
||||
(#lua-match? @variable.builtin "^%%"))
|
||||
|
||||
; Constructor
|
||||
((sym_lit) @constructor
|
||||
(#match? @constructor "^-\\>[^\\>].*"))
|
||||
(#lua-match? @constructor "^-\\>[^\\>].*"))
|
||||
|
||||
; Dynamic variables
|
||||
((sym_lit) @variable.builtin
|
||||
(#match? @variable.builtin "^[*].+[*]$"))
|
||||
(#lua-match? @variable.builtin "^[*].+[*]$"))
|
||||
|
||||
; Gensym
|
||||
;; Might not be needed
|
||||
((sym_lit) @variable
|
||||
(#match? @variable "^.*#$"))
|
||||
(#lua-match? @variable "^.*#$"))
|
||||
|
||||
; Types
|
||||
;; TODO: improve?
|
||||
((sym_lit) @type
|
||||
(#match? @type "^[A-Z][^/]*$"))
|
||||
(#lua-match? @type "^[%u][^/]*$"))
|
||||
;; Symbols with `.` but not `/`
|
||||
((sym_lit) @type
|
||||
(#match? @type "^[^/]+[.][^/]*$"))
|
||||
(#lua-match? @type "^[^/]+[.][^/]*$"))
|
||||
|
||||
; Interop
|
||||
((sym_lit) @method
|
||||
|
|
@ -88,11 +88,11 @@
|
|||
((sym_lit) @field
|
||||
(#match? @field "^\\.-"))
|
||||
((sym_lit) @field
|
||||
(#match? @field "^[A-Z].*/.+"))
|
||||
(#lua-match? @field "^[%u].*/.+"))
|
||||
(list_lit
|
||||
.
|
||||
(sym_lit) @method
|
||||
(#match? @method "^[A-Z].*/.+"))
|
||||
(#lua-match? @method "^[%u].*/.+"))
|
||||
;; TODO: Special casing for the `.` macro
|
||||
|
||||
; Operators
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@
|
|||
. (argument) @_transform @constant
|
||||
. (argument) @variable
|
||||
. (argument) @_action @constant
|
||||
(#match? @_transform "TRANSFORM")
|
||||
(#eq? @_transform "TRANSFORM")
|
||||
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
||||
)
|
||||
(normal_command
|
||||
|
|
@ -169,7 +169,7 @@
|
|||
. (argument) @variable
|
||||
. (argument) @_action @constant
|
||||
. (argument)? @_selector @constant
|
||||
(#match? @_transform "TRANSFORM")
|
||||
(#eq? @_transform "TRANSFORM")
|
||||
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
|
||||
(#any-of? @_selector "AT" "FOR" "REGEX")
|
||||
)
|
||||
|
|
@ -179,8 +179,8 @@
|
|||
. (argument) @_transform @constant
|
||||
(argument) @constant .
|
||||
(argument) @variable
|
||||
(#match? @_transform "TRANSFORM")
|
||||
(#match? @constant "OUTPUT_VARIABLE")
|
||||
(#eq? @_transform "TRANSFORM")
|
||||
(#eq? @constant "OUTPUT_VARIABLE")
|
||||
)
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
(num_lit) @number
|
||||
|
||||
((sym_lit) @boolean (#match? @boolean "^(t|T)$"))
|
||||
((sym_lit) @boolean (#any-of? @boolean "t" "T"))
|
||||
|
||||
(nil_lit) @constant.builtin
|
||||
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
|
||||
;; dynamic variables
|
||||
((sym_lit) @variable.builtin
|
||||
(#match? @variable.builtin "^[*].+[*]$"))
|
||||
(#lua-match? @variable.builtin "^[*].+[*]$"))
|
||||
|
||||
;; quote
|
||||
"'" @string.escape
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
|
||||
;; constant
|
||||
((sym_lit) @constant
|
||||
(#match? @constant "^[+].+[+]$"))
|
||||
(#lua-match? @constant "^[+].+[+]$"))
|
||||
|
||||
(var_quoting_lit
|
||||
marker: "#'" @symbol
|
||||
|
|
@ -180,7 +180,7 @@
|
|||
|
||||
|
||||
((sym_lit) @symbol
|
||||
(#match? @symbol "^[&]"))
|
||||
(#lua-match? @symbol "^[&]"))
|
||||
|
||||
[(array_dimension) "#0A" "#0a"] @number
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@
|
|||
(sym_lit) @_deftest
|
||||
.
|
||||
(sym_lit) @definition.function
|
||||
(#match? @_deftest "^(deftest)$")) @scope
|
||||
(#eq? @_deftest "deftest")) @scope
|
||||
|
||||
(list_lit
|
||||
.
|
||||
(sym_lit) @_deftest
|
||||
.
|
||||
(sym_lit) @definition.function
|
||||
(#match? @_deftest "^(deftest)$")) @scope
|
||||
(#eq? @_deftest "deftest")) @scope
|
||||
|
||||
(for_clause . (sym_lit) @definition.var)
|
||||
(with_clause . (sym_lit) @definition.var)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
; inherits: c
|
||||
|
||||
((identifier) @field
|
||||
(#match? @field "(^_|^m_|_$)"))
|
||||
(#lua-match? @field "^m?_.*$"))
|
||||
|
||||
(parameter_declaration
|
||||
declarator: (reference_declarator) @parameter)
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
(namespace_identifier) @namespace
|
||||
((namespace_identifier) @type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
(#lua-match? @type "^[%u]"))
|
||||
|
||||
(case_statement
|
||||
value: (qualified_identifier (identifier) @constant))
|
||||
|
|
@ -135,26 +135,26 @@
|
|||
((function_declarator
|
||||
(qualified_identifier
|
||||
(identifier) @constructor))
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
((call_expression
|
||||
function: (identifier) @constructor)
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
((call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @constructor))
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
((call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @constructor))
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
;; constructing a type in an initializer list: Constructor (): **SuperType (1)**
|
||||
((field_initializer
|
||||
(field_identifier) @constructor
|
||||
(argument_list))
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
|
||||
; Constants
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@
|
|||
(namespace_name) @namespace
|
||||
|
||||
((property_name) @type.definition
|
||||
(#match? @type.definition "^--"))
|
||||
(#lua-match? @type.definition "^[-][-]"))
|
||||
((plain_value) @type
|
||||
(#match? @type "^--"))
|
||||
(#lua-match? @type "^[-][-]"))
|
||||
|
||||
[
|
||||
(string_value)
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
(primitive_type) @type.builtin
|
||||
|
||||
((identifier) @type
|
||||
(#match? @type "^(#|_#)"))
|
||||
(#lua-match? @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
|
||||
; specifically identify a node as a function call
|
||||
(((identifier) @function (#match? @function "^_?[a-z]"))
|
||||
(((identifier) @function (#lua-match? @function "^_?[%l]"))
|
||||
. (selector . (argument_part))) @function
|
||||
|
||||
; Annotations
|
||||
|
|
@ -100,7 +100,7 @@
|
|||
((scoped_identifier
|
||||
scope: (identifier) @type
|
||||
name: (identifier) @type)
|
||||
(#match? @type "^[a-zA-Z]"))
|
||||
(#lua-match? @type "^[%u%l]"))
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
(inferred_type) @keyword
|
||||
|
||||
((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)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
([
|
||||
(let_binding (label) @type)
|
||||
(union_type_entry (label) @type)
|
||||
] (#match? @type "^[A-Z]"))
|
||||
] (#lua-match? @type "^%u"))
|
||||
|
||||
((primitive_expression
|
||||
(identifier (label) @type)
|
||||
|
|
|
|||
|
|
@ -55,9 +55,3 @@
|
|||
|
||||
(expose_instruction
|
||||
(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
|
||||
((identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
(#lua-match? @type "^%u"))
|
||||
|
||||
((identifier) @symbol
|
||||
(#match? @symbol "^[a-z]"))
|
||||
(#lua-match? @symbol "^%l"))
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
|
||||
(#lua-match? @constant "^%u[%u%d_]+$"))
|
||||
|
||||
;;; Punctuation ;;;;
|
||||
[
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@
|
|||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @_prop
|
||||
(#match? @_prop "(out|inn)erHTML"))
|
||||
(#any-of? @_prop "innerHTML" "outerHTML"))
|
||||
right: (template_string) @html
|
||||
(#offset! @html 0 1 0 -1))
|
||||
|
||||
|
|
@ -98,6 +98,6 @@
|
|||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @_prop
|
||||
(#match? @_prop "(out|inn)erHTML"))
|
||||
(#any-of? @_prop "innerHTML" "outerHTML"))
|
||||
right: (string) @html
|
||||
(#offset! @html 0 1 0 -1))
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
(identifier) @variable
|
||||
|
||||
; Unused Identifiers
|
||||
((identifier) @comment (#match? @comment "^_"))
|
||||
((identifier) @comment (#lua-match? @comment "^_"))
|
||||
|
||||
; Comments
|
||||
(comment) @comment @spell
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
(list . (multi_symbol (symbol) @function .))
|
||||
|
||||
((symbol) @variable.builtin
|
||||
(#match? @variable.builtin "^[$]"))
|
||||
(#lua-match? @variable.builtin "^[$]"))
|
||||
|
||||
(binding) @symbol
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
;; match operators of test 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]+)$"))
|
||||
|
||||
;; match operators of [ command
|
||||
(command
|
||||
name: (word) @punctuation.bracket (#match? @punctuation.bracket "^\\[$")
|
||||
name: (word) @punctuation.bracket (#eq? @punctuation.bracket "[")
|
||||
argument: (word) @operator (#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
||||
|
||||
[
|
||||
|
|
@ -106,7 +106,7 @@
|
|||
|
||||
(command
|
||||
argument: [
|
||||
(word) @parameter (#match? @parameter "^-")
|
||||
(word) @parameter (#lua-match? @parameter "^[-]")
|
||||
]
|
||||
)
|
||||
|
||||
|
|
@ -137,7 +137,7 @@
|
|||
option: [
|
||||
(word)
|
||||
(concatenation (word))
|
||||
] @parameter (#match? @parameter "^-")
|
||||
] @parameter (#lua-match? @parameter "^[-]")
|
||||
)
|
||||
|
||||
;; Strings
|
||||
|
|
@ -160,7 +160,7 @@
|
|||
(#any-of? @boolean "true" "false"))
|
||||
|
||||
((program . (comment) @preproc)
|
||||
(#match? @preproc "^#!/"))
|
||||
(#lua-match? @preproc "^#!/"))
|
||||
|
||||
;; Error
|
||||
|
||||
|
|
|
|||
|
|
@ -23,16 +23,11 @@
|
|||
directive: (identifier)* @conditional
|
||||
argument: (identifier)* @namespace
|
||||
)
|
||||
(
|
||||
(preproc_call
|
||||
argument: (identifier)* @namespace
|
||||
) @conditional
|
||||
(#match? @conditional "ifeq")
|
||||
)
|
||||
(
|
||||
(preproc_call) @conditional
|
||||
(#match? @conditional "(else|endif)")
|
||||
)
|
||||
((preproc_call
|
||||
argument: (identifier)* @namespace) @conditional
|
||||
(#eq? @conditional "ifeq"))
|
||||
((preproc_call) @conditional
|
||||
(#any-of? @conditional "else" "endif"))
|
||||
|
||||
;; Literal numbers and strings
|
||||
(number_literal) @float
|
||||
|
|
@ -64,6 +59,7 @@
|
|||
] @punctuation.delimiter
|
||||
|
||||
;; Special identifiers
|
||||
([(identifier) "on" "off" "true" "false" "yes" "no"] @constant.builtin
|
||||
(#match? @constant.builtin "^(uniform|non-uniform|and|or|on|off|true|false|yes|no)$")
|
||||
)
|
||||
[ "on" "off" "true" "false" "yes" "no" ] @constant.builtin
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "uniform" "non-uniform" "and" "or"))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
(eel_object_path
|
||||
(eel_path_identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^(this|props)$")
|
||||
(#any-of? @variable.builtin "this" "props")
|
||||
)
|
||||
|
||||
(eel_object_path
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
; Tags that start with a lower case letter are HTML tags
|
||||
; We'll also use this highlighting for named blocks (which start with `:`)
|
||||
((tag_name) @tag
|
||||
(#match? @tag "^(:)?[a-z]"))
|
||||
(#lua-match? @tag "^:?[%l]"))
|
||||
; Tags that start with a capital letter are Glimmer components
|
||||
((tag_name) @constructor
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
(attribute_name) @property
|
||||
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
(path_expression (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
|
||||
(block_statement_start argument: [
|
||||
(path_expression (identifier) @variable)
|
||||
|
|
@ -51,10 +51,10 @@
|
|||
(path_expression (identifier) @variable)
|
||||
(identifier) @variable
|
||||
])
|
||||
(#not-match? @variable "this"))
|
||||
(#not-eq? @variable "this"))
|
||||
; `this` should be highlighted as a built-in variable
|
||||
((identifier) @variable.builtin
|
||||
(#lua-match? @variable.builtin "this"))
|
||||
(#eq? @variable.builtin "this"))
|
||||
|
||||
; If the identifier is just "yield" or "outlet", it's a keyword
|
||||
((mustache_statement (identifier) @keyword)
|
||||
|
|
@ -65,11 +65,11 @@
|
|||
(path_expression (identifier) @function)
|
||||
(identifier) @function
|
||||
])
|
||||
(#not-match? @function "if|yield"))
|
||||
(#not-any-of? @function "if" "yield"))
|
||||
((helper_invocation helper: (identifier) @conditional)
|
||||
(#lua-match? @conditional "if"))
|
||||
(#eq? @conditional "if"))
|
||||
((helper_invocation helper: (identifier) @keyword)
|
||||
(#lua-match? @keyword "yield"))
|
||||
(#eq? @keyword "yield"))
|
||||
|
||||
(hash_pair key: (identifier) @property)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@
|
|||
(#match? @_tag "^(h[0-9]|title)$"))
|
||||
|
||||
((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)
|
||||
(#match? @_tag "^(em|i)$"))
|
||||
(#any-of? @_tag "em" "i"))
|
||||
|
||||
((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)
|
||||
(#eq? @_tag "u"))
|
||||
|
||||
((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)
|
||||
(#eq? @_tag "a"))
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value (attribute_value) @text.uri))
|
||||
(#match? @_attr "^(href|src)$"))
|
||||
(#any-of? @_attr "href" "src"))
|
||||
|
||||
[
|
||||
"<"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
(assignment)
|
||||
(const_declaration)
|
||||
]
|
||||
(#match? @markdown "^\"\"\"")
|
||||
(#lua-match? @markdown "^\"\"\"")
|
||||
(#offset! @markdown 0 3 0 -3))
|
||||
|
||||
[
|
||||
|
|
|
|||
|
|
@ -58,10 +58,8 @@
|
|||
(application_expression
|
||||
function: (value_path (value_name) @function))
|
||||
|
||||
(
|
||||
(value_name) @function.builtin
|
||||
(#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
|
||||
)
|
||||
((value_name) @function.builtin
|
||||
(#any-of? @function.builtin "raise" "raise_notrace" "failwith" "invalid_arg"))
|
||||
|
||||
; Properties
|
||||
;-----------
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@
|
|||
(comments) @spell
|
||||
|
||||
((source_file . (comments) @preproc)
|
||||
(#match? @preproc "^#!/"))
|
||||
(#lua-match? @preproc "^#!/"))
|
||||
|
||||
; POD should be handled specially with its own embedded subtype but for now
|
||||
; we'll just have to do this.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
((attribute
|
||||
attribute: (identifier) @field)
|
||||
(#match? @field "^([A-Z])@!.*$"))
|
||||
(#lua-match? @field "^%u@!.*$"))
|
||||
|
||||
((identifier) @type.builtin
|
||||
(#any-of? @type.builtin
|
||||
|
|
@ -71,12 +71,12 @@
|
|||
|
||||
((call
|
||||
function: (identifier) @constructor)
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
((call
|
||||
function: (attribute
|
||||
attribute: (identifier) @constructor))
|
||||
(#lua-match? @constructor "^[A-Z]"))
|
||||
(#lua-match? @constructor "^%u"))
|
||||
|
||||
;; Decorators
|
||||
|
||||
|
|
@ -170,7 +170,7 @@
|
|||
(comment) @comment @spell
|
||||
|
||||
((module . (comment) @preproc)
|
||||
(#match? @preproc "^#!/"))
|
||||
(#lua-match? @preproc "^#!/"))
|
||||
|
||||
(string) @string
|
||||
(escape_sequence) @string.escape
|
||||
|
|
@ -324,14 +324,14 @@
|
|||
(expression_statement
|
||||
(assignment
|
||||
left: (identifier) @field))))
|
||||
(#match? @field "^([A-Z])@!.*$"))
|
||||
(#lua-match? @field "^%u@!.*$"))
|
||||
((class_definition
|
||||
body: (block
|
||||
(expression_statement
|
||||
(assignment
|
||||
left: (_
|
||||
(identifier) @field)))))
|
||||
(#match? @field "^([A-Z])@!.*$"))
|
||||
(#lua-match? @field "^%u@!.*$"))
|
||||
|
||||
((class_definition
|
||||
(block
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@
|
|||
(predefined_type) @type.builtin
|
||||
|
||||
((identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
(#lua-match? @type "^%u"))
|
||||
|
||||
(type_arguments
|
||||
"<" @punctuation.bracket
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
(comment) @comment @spell
|
||||
|
||||
((program . (comment) @preproc)
|
||||
(#match? @preproc "^#!/"))
|
||||
(#lua-match? @preproc "^#!/"))
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
(symbol) @variable
|
||||
|
||||
((symbol) @comment
|
||||
(#match? @comment "^#[cC][iIsS]$"))
|
||||
(#lua-match? @comment "^#[cC][iIsS]$"))
|
||||
|
||||
;; extension ;;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,10 @@
|
|||
(#lua-match? @keyword.return "^return"))
|
||||
|
||||
((opcode) @conditional
|
||||
(#match? @conditional "^(if|cmp)"))
|
||||
(#lua-match? @conditional "^if"))
|
||||
|
||||
((opcode) @conditional
|
||||
(#lua-match? @conditional "^cmp"))
|
||||
|
||||
((opcode) @exception
|
||||
(#lua-match? @exception "^throw"))
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
((attribute
|
||||
attribute: (identifier) @field)
|
||||
(#match? @field "^([A-Z])@!.*$"))
|
||||
(#lua-match? @field "^%u@!.*$"))
|
||||
|
||||
((identifier) @type.builtin
|
||||
(#any-of? @type.builtin
|
||||
|
|
@ -148,7 +148,7 @@
|
|||
(comment) @comment @spell
|
||||
|
||||
((module . (comment) @preproc)
|
||||
(#match? @preproc "^#!/"))
|
||||
(#lua-match? @preproc "^#!/"))
|
||||
|
||||
(string) @string
|
||||
[
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
(#eq? @exception "catch"))
|
||||
|
||||
((special_block_keyword) @conditional
|
||||
(#match? @conditional "^(if|else)$"))
|
||||
(#any-of? @conditional "if" "else"))
|
||||
|
||||
[
|
||||
"{"
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@
|
|||
(
|
||||
(command_expression
|
||||
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
|
||||
|
|
@ -97,14 +97,14 @@
|
|||
(identifier) @constant)
|
||||
(
|
||||
(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: (identifier) @keyword
|
||||
arguments: (argument_list . (identifier) @label))
|
||||
(#match? @keyword "^[gG][oO][tT][oO]$")
|
||||
(#lua-match? @keyword "^[gG][oO][tT][oO]$")
|
||||
)
|
||||
(labeled_expression
|
||||
label: (identifier) @label)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
; Built-ins {{{
|
||||
((function_call
|
||||
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
|
||||
; (#is-not? local)
|
||||
)
|
||||
|
||||
((type_identifier) @type.builtin
|
||||
(#match? @type.builtin "^(int|string|Object)$")
|
||||
(#any-of? @type.builtin "int" "string" "Object")
|
||||
; FIXME: not supported by neovim
|
||||
; (#is-not? local)
|
||||
)
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^self$")
|
||||
(#eq? @variable.builtin "self")
|
||||
; FIXME: not supported by neovim
|
||||
; (#is-not? local)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
(#not-has-parent? @_parent call_expression special_call_expression)))
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^(err|macos|linux|windows)$"))
|
||||
(#any-of? @variable.builtin "err" "macos" "linux" "windows"))
|
||||
|
||||
(attribute_declaration) @attribute
|
||||
;; C: TODO: fixme make `C`.exten highlighted as variable.builtin
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
; highlight constants
|
||||
(
|
||||
(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)
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$")
|
||||
(#lua-match? @constant "^[%u][%u%d_]*$")
|
||||
)
|
||||
|
||||
; highlight types and probable types
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
; highlight creation methods in object creation expressions
|
||||
(
|
||||
(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))
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@
|
|||
|
||||
; Options
|
||||
((set_value) @number
|
||||
(#match? @number "^[0-9]+(\.[0-9]+)?$"))
|
||||
(#lua-match? @number "^[%d]+(%.[%d]+)?$"))
|
||||
|
||||
(inv_option "!" @operator)
|
||||
(set_item "?" @operator)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ parameter: (IDENTIFIER) @parameter
|
|||
field_access: (IDENTIFIER)
|
||||
parameter: (IDENTIFIER)
|
||||
] @type
|
||||
(#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$")
|
||||
(#lua-match? @type "^%u([%l]+[%u%l%d]*)*$")
|
||||
)
|
||||
;; assume camelCase is a function
|
||||
(
|
||||
|
|
@ -33,7 +33,7 @@ parameter: (IDENTIFIER) @parameter
|
|||
field_access: (IDENTIFIER)
|
||||
parameter: (IDENTIFIER)
|
||||
] @function
|
||||
(#match? @function "^[a-z]+([A-Z][a-z0-9]*)+$")
|
||||
(#lua-match? @function "^%l+([%u][%l%d]*)+$")
|
||||
)
|
||||
|
||||
;; assume all CAPS_1 is a constant
|
||||
|
|
@ -42,7 +42,7 @@ parameter: (IDENTIFIER) @parameter
|
|||
variable_type_function: (IDENTIFIER)
|
||||
field_access: (IDENTIFIER)
|
||||
] @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