aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravonteD <tman1300@aol.com>2020-06-19 09:59:27 -0400
committerTravonteD <tman1300@aol.com>2020-06-20 09:03:39 -0400
commit0f836e060266c73e77871bd85b91f4159556035d (patch)
treeec3458ca006ac42e71323acbcb181ad601f501e2
parentMerge pull request #88 from PitcherTear22/master (diff)
downloadnvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.tar
nvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.tar.gz
nvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.tar.bz2
nvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.tar.lz
nvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.tar.xz
nvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.tar.zst
nvim-treesitter-0f836e060266c73e77871bd85b91f4159556035d.zip
refactor: use newly introduced consolidated syntax
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--queries/css/highlights.scm125
-rw-r--r--queries/html/highlights.scm11
-rw-r--r--queries/ruby/highlights.scm188
-rw-r--r--queries/ruby/locals.scm6
5 files changed, 197 insertions, 135 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5a8c74ee6..568a47e3b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -29,6 +29,7 @@ Here are some global advices :
- If not, you should consider installing the [tree-sitter cli](https://github.com/tree-sitter/tree-sitter/tree/master/cli),
you should then be able to open a local playground using `tree-sitter build-wasm && tree-sitter web-ui` within the
parsers repo.
+ - An Example of somewhat complex highlight queries can be found in queries/ruby/highlights.scm (Maintained by @TravonteD)
### Highlights
@@ -36,6 +37,7 @@ As languages differ quite a lot, here is a set of captures available to you when
One important thing to note is that many of these capture groups are not supported by `neovim` for now, and will not have any
effect on highlighting. We will work on improving highlighting in the near future though.
+
#### Misc
`@comment`
`@error` for error `(ERROR)` nodes.
diff --git a/queries/css/highlights.scm b/queries/css/highlights.scm
index 72009e765..1b876c4b1 100644
--- a/queries/css/highlights.scm
+++ b/queries/css/highlights.scm
@@ -1,72 +1,91 @@
-"@media" @keyword
-"@import" @include
-"@charset" @keyword
-"@namespace" @keyword
-"@supports" @keyword
-"@keyframes" @keyword
-(at_keyword) @keyword
-(to) @keyword
-(from) @keyword
-(important) @keyword
+[
+ "@media"
+ "@import"
+ "@charset"
+ "@namespace"
+ "@supports"
+ "@keyframes"
+ (at_keyword)
+ (to)
+ (from)
+ (important)
+ ] @keyword
(comment) @comment
-(tag_name) @type
-(nesting_selector) @type
-(universal_selector) @type
+[
+ (tag_name)
+ (nesting_selector)
+ (universal_selector)
+ ] @type
(function_name) @function
-"~" @operator
-">" @operator
-"+" @operator
-"-" @operator
-"*" @operator
-"/" @operator
-"=" @operator
-"^=" @operator
-"|=" @operator
-"~=" @operator
-"$=" @operator
-"*=" @operator
+[
+ "~"
+ ">"
+ "+"
+ "-"
+ "*"
+ "/"
+ "="
+ "^="
+ "|="
+ "~="
+ "$="
+ "*="
+ "and"
+ "or"
+ "not"
+ "only"
+ ] @operator
-"and" @operator
-"or" @operator
-"not" @operator
-"only" @operator
(attribute_selector (plain_value) @string)
(pseudo_element_selector (tag_name) @property)
(pseudo_class_selector (class_name) @property)
-(class_name) @property
-(id_name) @property
-(namespace_name) @property
-(property_name) @property
-(feature_name) @property
-(attribute_name) @property
+[
+ (class_name)
+ (id_name)
+ (namespace_name)
+ (property_name)
+ (feature_name)
+ (attribute_name)
+ ] @property
((property_name) @type
- (#match? @type "^--"))
+ (#match? @type "^--"))
((plain_value) @type
- (#match? @type "^--"))
+ (#match? @type "^--"))
-(string_value) @string
-(color_value) @string
-(identifier) @string
+[
+ (string_value)
+ (color_value)
+ (identifier)
+ (unit)
+ ] @string
-(integer_value) @number
-(float_value) @number
-(unit) @string
+[
+ (integer_value)
+ (float_value)
+ ] @number
-"#" @punctuation.delimiter
-"," @punctuation.delimiter
-"." @punctuation.delimiter
-":" @punctuation.delimiter
-"::" @punctuation.delimiter
-";" @punctuation.delimiter
-"{" @punctuation.bracket
-")" @punctuation.bracket
-"(" @punctuation.bracket
-"}" @punctuation.bracket
+[
+ "#"
+ ","
+ "."
+ ":"
+ "::"
+ ";"
+ ] @punctuation.delimiter
+
+[
+ "{"
+ ")"
+ "("
+ "}"
+ ] @punctuation.bracket
+
+(ERROR) @error
diff --git a/queries/html/highlights.scm b/queries/html/highlights.scm
index 582e1e46f..1e83ecf4c 100644
--- a/queries/html/highlights.scm
+++ b/queries/html/highlights.scm
@@ -8,8 +8,9 @@
"=" @operator
-"<" @punctuation.bracket
-">" @punctuation.bracket
-"</" @punctuation.bracket
-"/>" @punctuation.bracket
-
+[
+ "<"
+ ">"
+ "</"
+ "/>"
+ ] @punctuation.bracket
diff --git a/queries/ruby/highlights.scm b/queries/ruby/highlights.scm
index 9e5852cdf..21afbe809 100644
--- a/queries/ruby/highlights.scm
+++ b/queries/ruby/highlights.scm
@@ -1,32 +1,41 @@
; Keywords
-"alias" @keyword
-"and" @keyword
-"begin" @keyword
-"break" @keyword
-"case" @conditional
-"class" @keyword
-"def" @keyword
-"do" @keyword
-"else" @conditional
-"elsif" @conditional
-"end" @keyword
-"ensure" @keyword
-"for" @repeat
-"if" @conditional
-"in" @keyword
-"module" @keyword
-"next" @keyword
-"or" @keyword
-"rescue" @keyword
-"retry" @keyword
-"return" @keyword
-"then" @keyword
-"unless" @conditional
-"until" @repeat
-"when" @conditional
-"while" @repeat
-"yield" @keyword
+[
+ "alias"
+ "and"
+ "begin"
+ "break"
+ "class"
+ "def"
+ "do"
+ "end"
+ "ensure"
+ "in"
+ "module"
+ "next"
+ "or"
+ "rescue"
+ "retry"
+ "return"
+ "then"
+ "yield"
+ ] @keyword
+
+[
+ "case"
+ "else"
+ "elsif"
+ "if"
+ "unless"
+ "when"
+ ] @conditional
+
+[
+ "for"
+ "until"
+ "while"
+ ] @repeat
+
((identifier) @keyword
(#match? @keyword "^(private|protected|public)$"))
@@ -39,32 +48,45 @@
"defined?" @function
(call
- receiver: (constant) @constant)
-(method_call
- receiver: (constant) @constant)
-(call
- method: (identifier) @function)
-(method_call
- method: (identifier) @function)
-(call
- method: (constant) @function)
+ [
+ receiver: (constant) @constant
+ method: [
+ (identifier)
+ (constant)
+ ] @function
+ ])
+
(method_call
- method: (constant) @function)
+ [
+ receiver: (constant) @constant
+ method: [
+ (identifier)
+ (constant)
+ ] @function
+ ])
; Function definitions
(alias (identifier) @function)
(setter (identifier) @function)
-(method name: (identifier) @function)
-(method name: (constant) @constant)
+
+(method name: [
+ (identifier) @function
+ (constant) @constant
+ ])
+
+(singleton_method name: [
+ (identifier) @function
+ (constant) @constant
+ ])
+
(class name: (constant) @constant)
-(singleton_method name: (identifier) @function)
-(singleton_method name: (constant) @constant)
; Identifiers
-
-(class_variable) @label
-(instance_variable) @label
+[
+ (class_variable)
+ (instance_variable)
+ ] @label
((identifier) @constant.builtin
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
@@ -74,8 +96,10 @@
(constant) @constant
-(self) @constant.builtin
-(super) @constant.builtin
+[
+ (self)
+ (super)
+ ] @constant.builtin
(method_parameters (identifier) @parameter)
(lambda_parameters (identifier) @parameter)
@@ -93,22 +117,30 @@
; Literals
-(string) @string
-(bare_string) @string
-(bare_symbol) @constant
-(subshell) @string
-(heredoc_beginning) @constant
-(heredoc_body) @string
-(heredoc_end) @constant
-(symbol) @constant
+[
+ (string)
+ (bare_string)
+ (subshell)
+ (heredoc_body)
+ ] @string
+
+[
+ (bare_symbol)
+ (heredoc_beginning)
+ (heredoc_end)
+ (symbol)
+ ] @constant
+
(regex) @string.regex
(escape_sequence) @string.escape
(integer) @number
(float) @float
-(nil) @boolean
-(true) @boolean
-(false) @boolean
+[
+ (nil)
+ (true)
+ (false)
+ ] @boolean
(interpolation
"#{" @punctuation.bracket
@@ -118,25 +150,31 @@
; Operators
-"=" @operator
-"=>" @operator
-"->" @operator
-"+" @operator
-"-" @operator
-"*" @operator
-"/" @operator
+[
+ "="
+ "=>"
+ "->"
+ "+"
+ "-"
+ "*"
+ "/"
+ ] @operator
-"," @punctuation.delimiter
-";" @punctuation.delimiter
-"." @punctuation.delimiter
+[
+ ","
+ ";"
+ "."
+ ] @punctuation.delimiter
-"(" @punctuation.bracket
-")" @punctuation.bracket
-"[" @punctuation.bracket
-"]" @punctuation.bracket
-"{" @punctuation.bracket
-"}" @punctuation.bracket
-"%w(" @punctuation.bracket
-"%i(" @punctuation.bracket
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+ "%w("
+ "%i("
+ ] @punctuation.bracket
(ERROR) @error
diff --git a/queries/ruby/locals.scm b/queries/ruby/locals.scm
index f50c2cc99..fe5122d2d 100644
--- a/queries/ruby/locals.scm
+++ b/queries/ruby/locals.scm
@@ -24,8 +24,10 @@
((method) @scope
(set! scope-inherits false))
-(block) @scope
-(do_block) @scope
+[
+ (block)
+ (do_block)
+ ] @scope
(method_parameters (identifier) @definition.function)
(lambda_parameters (identifier) @definition.function)