aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2021-11-18 09:51:03 +0000
committerStephan Seitz <stephan.seitz@fau.de>2021-11-23 10:02:06 +0100
commit011ac894ec5b9e36563d8629fb7734f43ddb27a8 (patch)
treede0b252b7705bfa4304c08cd389fed0814ae6f1c
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.tar
nvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.tar.gz
nvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.tar.bz2
nvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.tar.lz
nvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.tar.xz
nvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.tar.zst
nvim-treesitter-011ac894ec5b9e36563d8629fb7734f43ddb27a8.zip
Prefer lua-match over match
as string.find is much quicker than vim.regex:match*
-rw-r--r--queries/bash/highlights.scm4
-rw-r--r--queries/c/highlights.scm2
-rw-r--r--queries/clojure/highlights.scm6
-rw-r--r--queries/comment/highlights.scm4
-rw-r--r--queries/cpp/highlights.scm14
-rw-r--r--queries/dockerfile/highlights.scm2
-rw-r--r--queries/ecma/highlights.scm6
-rw-r--r--queries/gdscript/highlights.scm6
-rw-r--r--queries/glimmer/highlights.scm10
-rw-r--r--queries/java/highlights.scm6
-rw-r--r--queries/jsx/highlights.scm6
-rw-r--r--queries/lua/highlights.scm2
-rw-r--r--queries/lua/injections.scm8
-rw-r--r--queries/php/highlights.scm2
-rw-r--r--queries/python/highlights.scm12
-rw-r--r--queries/python/injections.scm2
-rw-r--r--queries/rust/highlights.scm20
-rw-r--r--queries/scala/highlights.scm16
-rw-r--r--queries/teal/injections.scm4
-rw-r--r--queries/vim/highlights.scm2
20 files changed, 67 insertions, 67 deletions
diff --git a/queries/bash/highlights.scm b/queries/bash/highlights.scm
index 546228485..7e49e5c90 100644
--- a/queries/bash/highlights.scm
+++ b/queries/bash/highlights.scm
@@ -102,7 +102,7 @@
])
((word) @number
- (#match? @number "^[0-9]+$"))
+ (#lua-match? @number "^[0-9]+$"))
(file_redirect
descriptor: (file_descriptor) @operator
@@ -114,7 +114,7 @@
(variable_name) @variable
((variable_name) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(case_item
value: (word) @parameter)
diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm
index c3a9db172..3eb687b97 100644
--- a/queries/c/highlights.scm
+++ b/queries/c/highlights.scm
@@ -138,7 +138,7 @@
(sizeof_expression value: (parenthesized_expression (identifier) @type))
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z0-9_]+$"))
+ (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
;; Preproc def / undef
(preproc_def
diff --git a/queries/clojure/highlights.scm b/queries/clojure/highlights.scm
index e8fd61145..d6371c522 100644
--- a/queries/clojure/highlights.scm
+++ b/queries/clojure/highlights.scm
@@ -55,7 +55,7 @@
; Used in destructure pattern
((sym_lit) @parameter
- (#match? @parameter "^[&]"))
+ (#lua-match? @parameter "^[&]"))
; Inline function variables
((sym_lit) @variable.builtin
@@ -106,7 +106,7 @@
; Definition functions
((sym_lit) @keyword
- (#match? @keyword "^def.*$"))
+ (#lua-match? @keyword "^def.*$"))
((sym_lit) @keyword
(#eq? @keyword "declare"))
((sym_lit) @keyword.function
@@ -283,7 +283,7 @@
(list_lit
.
(sym_lit) @_keyword ; Don't really want to highlight twice
- (#match? @_keyword "^def.*")
+ (#lua-match? @_keyword "^def.*")
.
(sym_lit)
.
diff --git a/queries/comment/highlights.scm b/queries/comment/highlights.scm
index c8b086c8a..6c3e043c8 100644
--- a/queries/comment/highlights.scm
+++ b/queries/comment/highlights.scm
@@ -20,6 +20,6 @@
(#any-of? @text.danger "FIXME" "XXX" "BUG"))
; Issue number (#123)
-("text" @number (#match? @number "^#[0-9]+$"))
+("text" @number (#lua-match? @number "^#[0-9]+$"))
; User mention (@user)
-("text" @constant (#match? @constant "^[@][a-zA-Z0-9_-]+$"))
+("text" @constant (#lua-match? @constant "^[@][a-zA-Z0-9_-]+$"))
diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm
index 309f72d93..c860b632a 100644
--- a/queries/cpp/highlights.scm
+++ b/queries/cpp/highlights.scm
@@ -33,9 +33,9 @@
(namespace_identifier) @namespace
((namespace_identifier) @type
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
((namespace_identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(namespace_definition
name: (identifier) @namespace)
@@ -50,7 +50,7 @@
((function_declarator
declarator: (qualified_identifier
name: (identifier) @constructor))
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
(operator_name) @function
"static_assert" @function.builtin
@@ -65,22 +65,22 @@
((call_expression
function: (identifier) @constructor)
-(#match? @constructor "^[A-Z]"))
+(#lua-match? @constructor "^[A-Z]"))
((call_expression
function: (qualified_identifier
name: (identifier) @constructor))
-(#match? @constructor "^[A-Z]"))
+(#lua-match? @constructor "^[A-Z]"))
((call_expression
function: (field_expression
field: (field_identifier) @constructor))
-(#match? @constructor "^[A-Z]"))
+(#lua-match? @constructor "^[A-Z]"))
;; constructing a type in an initializer list: Constructor (): **SuperType (1)**
((field_initializer
(field_identifier) @constructor
(argument_list))
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
; Constants
diff --git a/queries/dockerfile/highlights.scm b/queries/dockerfile/highlights.scm
index 1d629648e..af1c088c5 100644
--- a/queries/dockerfile/highlights.scm
+++ b/queries/dockerfile/highlights.scm
@@ -45,6 +45,6 @@
)
((variable) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
diff --git a/queries/ecma/highlights.scm b/queries/ecma/highlights.scm
index 8bc2c0c81..1e43c7f6d 100644
--- a/queries/ecma/highlights.scm
+++ b/queries/ecma/highlights.scm
@@ -20,13 +20,13 @@
;--------------------
((identifier) @constructor
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
((identifier) @constant
- (#vim-match? @constant "^[A-Z_][A-Z\\d_]+$"))
+ (#lua-match? @constant "^[A-Z_][A-Z%d_]+$"))
((shorthand_property_identifier) @constant
- (#vim-match? @constant "^[A-Z_][A-Z\\d_]+$"))
+ (#lua-match? @constant "^[A-Z_][A-Z%d_]+$"))
((identifier) @variable.builtin
(#vim-match? @variable.builtin "^(arguments|module|console|window|document)$"))
diff --git a/queries/gdscript/highlights.scm b/queries/gdscript/highlights.scm
index a65afdc72..d86e4c1de 100644
--- a/queries/gdscript/highlights.scm
+++ b/queries/gdscript/highlights.scm
@@ -27,11 +27,11 @@
;; Identifier naming conventions
((identifier) @type
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((identifier) @type
- (#match? @type "^[A-Z][A-Z_0-9]*$") . (_))
+ (#lua-match? @type "^[A-Z][A-Z_0-9]*$") . (_))
;; Functions
(constructor_definition) @constructor
diff --git a/queries/glimmer/highlights.scm b/queries/glimmer/highlights.scm
index bcb9c8b5d..b1b3f9141 100644
--- a/queries/glimmer/highlights.scm
+++ b/queries/glimmer/highlights.scm
@@ -6,7 +6,7 @@
(#match? @tag "^(:)?[a-z]"))
; Tags that start with a capital letter are Glimmer components
((tag_name) @constructor
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
(attribute_name) @property
@@ -26,7 +26,7 @@
(block_statement_start path: (identifier) @conditional)
(block_statement_end path: (identifier) @conditional)
((mustache_statement (identifier) @conditional)
- (#match? @conditional "else"))
+ (#lua-match? @conditional "else"))
; == Mustache Statements ===
@@ -54,7 +54,7 @@
(#not-match? @variable "this"))
; `this` should be highlighted as a built-in variable
((identifier) @variable.builtin
- (#match? @variable.builtin "this"))
+ (#lua-match? @variable.builtin "this"))
; If the identifier is just "yield" or "outlet", it's a keyword
((mustache_statement (identifier) @keyword)
@@ -67,9 +67,9 @@
])
(#not-match? @function "if|yield"))
((helper_invocation helper: (identifier) @conditional)
- (#match? @conditional "if"))
+ (#lua-match? @conditional "if"))
((helper_invocation helper: (identifier) @keyword)
- (#match? @keyword "yield"))
+ (#lua-match? @keyword "yield"))
(hash_pair key: (identifier) @property)
diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm
index 6a2cf2f40..fc6f4bf07 100644
--- a/queries/java/highlights.scm
+++ b/queries/java/highlights.scm
@@ -95,10 +95,10 @@
((field_access
object: (identifier) @type)
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
((scoped_identifier
scope: (identifier) @type)
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
; Fields
@@ -118,7 +118,7 @@
; Variables
((identifier) @constant
- (#match? @constant "^[A-Z_][A-Z\d_]+$"))
+ (#lua-match? @constant "^[A-Z_][A-Z%d_]+$"))
(this) @variable.builtin
diff --git a/queries/jsx/highlights.scm b/queries/jsx/highlights.scm
index 8904c86c4..1f19c6b2a 100644
--- a/queries/jsx/highlights.scm
+++ b/queries/jsx/highlights.scm
@@ -16,19 +16,19 @@
name: (identifier) @tag)
(jsx_opening_element ((identifier) @constructor
- (#match? @constructor "^[A-Z]")))
+ (#lua-match? @constructor "^[A-Z]")))
; Handle the dot operator effectively - <My.Component>
(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
(jsx_closing_element ((identifier) @constructor
- (#match? @constructor "^[A-Z]")))
+ (#lua-match? @constructor "^[A-Z]")))
; Handle the dot operator effectively - </My.Component>
(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
(jsx_self_closing_element ((identifier) @constructor
- (#match? @constructor "^[A-Z]")))
+ (#lua-match? @constructor "^[A-Z]")))
; Handle the dot operator effectively - <My.Component />
(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm
index 842ed64da..2c7291b9f 100644
--- a/queries/lua/highlights.scm
+++ b/queries/lua/highlights.scm
@@ -116,7 +116,7 @@
(nil) @constant.builtin
(spread) @constant ;; "..."
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
;; Functions
(function [(function_name) (identifier)] @function)
diff --git a/queries/lua/injections.scm b/queries/lua/injections.scm
index 65b8b304b..fa05c40a7 100644
--- a/queries/lua/injections.scm
+++ b/queries/lua/injections.scm
@@ -8,7 +8,7 @@
)
(#eq? @_cdef_identifier "cdef")
- (#match? @c "^[\"']")
+ (#lua-match? @c "^[\"']")
(#offset! @c 0 1 0 -1)
)
@@ -21,7 +21,7 @@
)
(#eq? @_cdef_identifier "cdef")
- (#match? @c "^\\[\\[")
+ (#lua-match? @c "^%[%[")
(#offset! @c 0 2 0 -2)
)
@@ -34,7 +34,7 @@
)
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec")
- (#match? @vim "^[\"']")
+ (#lua-match? @vim "^[\"']")
(#offset! @vim 0 1 0 -1)
)
@@ -46,7 +46,7 @@
)
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec")
- (#match? @vim "^\\[\\[")
+ (#lua-match? @vim "^%[%[")
(#offset! @vim 0 2 0 -2)
)
diff --git a/queries/php/highlights.scm b/queries/php/highlights.scm
index d9d270516..8a66a11d8 100644
--- a/queries/php/highlights.scm
+++ b/queries/php/highlights.scm
@@ -56,7 +56,7 @@
(#vim-match? @constant "^_?[A-Z][A-Z\d_]+$"))
((name) @constructor
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
((name) @variable.builtin
(#eq? @variable.builtin "this"))
diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm
index 318780d18..423948e51 100644
--- a/queries/python/highlights.scm
+++ b/queries/python/highlights.scm
@@ -9,12 +9,12 @@
;; Identifier naming conventions
((identifier) @type
- (#match? @type "^[A-Z].*[a-z]"))
+ (#lua-match? @type "^[A-Z].*[a-z]"))
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((identifier) @constant.builtin
- (#match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
+ (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((identifier) @constant.builtin
(#any-of? @constant.builtin
@@ -64,12 +64,12 @@
((call
function: (identifier) @constructor)
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
((call
function: (attribute
attribute: (identifier) @constructor))
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
;; Builtin functions
@@ -133,7 +133,7 @@
(none) @constant.builtin
[(true) (false)] @boolean
((identifier) @variable.builtin
- (#match? @variable.builtin "^self$"))
+ (#lua-match? @variable.builtin "^self$"))
(integer) @number
(float) @float
diff --git a/queries/python/injections.scm b/queries/python/injections.scm
index 197e725e5..db966e6ca 100644
--- a/queries/python/injections.scm
+++ b/queries/python/injections.scm
@@ -3,7 +3,7 @@
object: (identifier) @_re)
arguments: (argument_list (string) @regex))
(#eq? @_re "re")
- (#match? @regex "^r.*"))
+ (#lua-match? @regex "^r.*"))
; Module docstring
((module . (expression_statement (string) @rst))
diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm
index af8e6e5aa..0a97e75b1 100644
--- a/queries/rust/highlights.scm
+++ b/queries/rust/highlights.scm
@@ -6,12 +6,12 @@
(identifier) @variable
((identifier) @type
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
(const_item
name: (identifier) @constant)
; Assume all-caps names are constants
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z\\d_]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
; Other identifiers
@@ -44,7 +44,7 @@
; Assume other uppercase names are enum constructors
((field_identifier) @constant
- (#match? @constant "^[A-Z]"))
+ (#lua-match? @constant "^[A-Z]"))
(enum_variant
name: (identifier) @constant)
@@ -62,10 +62,10 @@
name: (identifier) @namespace))
((scoped_identifier
path: (identifier) @type)
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
((scoped_identifier
name: (identifier) @type)
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
(crate) @namespace
(scoped_use_list
@@ -74,25 +74,25 @@
path: (scoped_identifier
(identifier) @namespace))
(use_list (scoped_identifier (identifier) @namespace . (_)))
-(use_list (identifier) @type (#match? @type "^[A-Z]"))
-(use_as_clause alias: (identifier) @type (#match? @type "^[A-Z]"))
+(use_list (identifier) @type (#lua-match? @type "^[A-Z]"))
+(use_as_clause alias: (identifier) @type (#lua-match? @type "^[A-Z]"))
;; Correct enum constructors
(call_expression
function: (scoped_identifier
"::"
name: (identifier) @constant)
- (#match? @constant "^[A-Z]"))
+ (#lua-match? @constant "^[A-Z]"))
; Assume uppercase names in a match arm are constants.
((match_arm
pattern: (match_pattern (identifier) @constant))
- (#match? @constant "^[A-Z]"))
+ (#lua-match? @constant "^[A-Z]"))
((match_arm
pattern: (match_pattern
(scoped_identifier
name: (identifier) @constant)))
- (#match? @constant "^[A-Z]"))
+ (#lua-match? @constant "^[A-Z]"))
((identifier) @constant.builtin
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm
index d8b39950e..7cf5906b0 100644
--- a/queries/scala/highlights.scm
+++ b/queries/scala/highlights.scm
@@ -5,7 +5,7 @@
(identifier) @variable
((identifier) @variable.builtin
- (#match? @variable.builtin "^this$"))
+ (#lua-match? @variable.builtin "^this$"))
(interpolation) @none
@@ -16,7 +16,7 @@
; an uppercased method as a constant if used with no params.
; Introducing highlighting for those specific cases, is probably
; best way to resolve the issue.
-((identifier) @constant (#match? @constant "^[A-Z]"))
+((identifier) @constant (#lua-match? @constant "^[A-Z]"))
;; types
@@ -56,10 +56,10 @@
((stable_identifier (identifier) @namespace))
((import_declaration
- path: (identifier) @type) (#match? @type "^[A-Z]"))
-((stable_identifier (identifier) @type) (#match? @type "^[A-Z]"))
+ path: (identifier) @type) (#lua-match? @type "^[A-Z]"))
+((stable_identifier (identifier) @type) (#lua-match? @type "^[A-Z]"))
-((import_selectors (identifier) @type) (#match? @type "^[A-Z]"))
+((import_selectors (identifier) @type) (#lua-match? @type "^[A-Z]"))
; method invocation
@@ -73,14 +73,14 @@
((call_expression
function: (identifier) @constructor)
- (#match? @constructor "^[A-Z]"))
+ (#lua-match? @constructor "^[A-Z]"))
(generic_function
function: (identifier) @function)
(
(identifier) @function.builtin
- (#match? @function.builtin "^super$")
+ (#lua-match? @function.builtin "^super$")
)
; function definitions
@@ -96,7 +96,7 @@
(field_expression field: (identifier) @property)
(field_expression value: (identifier) @type
- (#match? @type "^[A-Z]"))
+ (#lua-match? @type "^[A-Z]"))
(infix_expression operator: (identifier) @operator)
(infix_expression operator: (operator_identifier) @operator)
diff --git a/queries/teal/injections.scm b/queries/teal/injections.scm
index 5fceed10f..f37f4d747 100644
--- a/queries/teal/injections.scm
+++ b/queries/teal/injections.scm
@@ -7,7 +7,7 @@
)
(#eq? @_cdef_identifier "cdef")
- (#match? @c "^[\"']")
+ (#lua-match? @c "^[\"']")
(#offset! @c 0 1 0 -1)
)
@@ -20,7 +20,7 @@
)
(#eq? @_cdef_identifier "cdef")
- (#match? @c "^\\[\\[")
+ (#lua-match? @c "^%[%[")
(#offset! @c 0 2 0 -2)
)
diff --git a/queries/vim/highlights.scm b/queries/vim/highlights.scm
index a44e07ad3..beec86977 100644
--- a/queries/vim/highlights.scm
+++ b/queries/vim/highlights.scm
@@ -1,6 +1,6 @@
(identifier) @variable
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
;; Keywords