aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelianiva <dicha.arkana03@gmail.com>2021-05-05 16:40:36 +0700
committerStephan Seitz <stephan.lauf@yahoo.de>2021-05-17 23:38:14 +0200
commit5d2faa0466eea5c656cb9885aef68327976fa7ea (patch)
tree11f1193193b382635899d54fd685057f687dee52
parentfish: move `test` to `test_command` (diff)
downloadnvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.tar
nvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.tar.gz
nvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.tar.bz2
nvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.tar.lz
nvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.tar.xz
nvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.tar.zst
nvim-treesitter-5d2faa0466eea5c656cb9885aef68327976fa7ea.zip
refactor: make html-like languages inherit from single query
-rw-r--r--queries/html/highlights.scm44
-rw-r--r--queries/html_tags/highlights.scm42
-rw-r--r--queries/html_tags/injections.scm7
-rw-r--r--queries/svelte/highlights.scm47
-rw-r--r--queries/svelte/injections.scm8
-rw-r--r--queries/vue/highlights.scm22
-rw-r--r--queries/vue/injections.scm10
7 files changed, 61 insertions, 119 deletions
diff --git a/queries/html/highlights.scm b/queries/html/highlights.scm
index 97fd0d662..6da261c0a 100644
--- a/queries/html/highlights.scm
+++ b/queries/html/highlights.scm
@@ -1,43 +1,5 @@
-(tag_name) @tag
-(erroneous_end_tag_name) @error
-(doctype) @constant
-(attribute_name) @property
-(attribute_value) @string
-(quoted_attribute_value) @string
-(comment) @comment
-
-((element (start_tag (tag_name) @_tag) (text) @text.title)
- (#match? @_tag "^(h[0-9]|title)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.strong)
- (#match? @_tag "^(strong|b)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
- (#match? @_tag "^(em|i)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.strike)
- (#match? @_tag "^(s|del)$"))
+; inherits: html_tags
-((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)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.uri)
- (#eq? @_tag "a"))
-
-((attribute
- (attribute_name) @_attr
- (quoted_attribute_value (attribute_value) @text.uri))
- (#match? @_attr "^(href|src)$"))
-
-"=" @operator
+(doctype) @constant
-[
- "<"
- "<!"
- ">"
- "</"
- "/>"
-] @tag.delimiter
+"<!" @tag.delimiter
diff --git a/queries/html_tags/highlights.scm b/queries/html_tags/highlights.scm
new file mode 100644
index 000000000..f92881d27
--- /dev/null
+++ b/queries/html_tags/highlights.scm
@@ -0,0 +1,42 @@
+(tag_name) @tag
+(erroneous_end_tag_name) @error
+(comment) @comment
+(attribute_name) @property
+(attribute_value) @string
+(quoted_attribute_value) @string
+(text) @none
+
+((element (start_tag (tag_name) @_tag) (text) @text.title)
+ (#match? @_tag "^(h[0-9]|title)$"))
+
+((element (start_tag (tag_name) @_tag) (text) @text.strong)
+ (#match? @_tag "^(strong|b)$"))
+
+((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
+ (#match? @_tag "^(em|i)$"))
+
+((element (start_tag (tag_name) @_tag) (text) @text.strike)
+ (#match? @_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)$"))
+
+((element (start_tag (tag_name) @_tag) (text) @text.uri)
+ (#eq? @_tag "a"))
+
+((attribute
+ (attribute_name) @_attr
+ (quoted_attribute_value (attribute_value) @text.uri))
+ (#match? @_attr "^(href|src)$"))
+
+[
+ "<"
+ ">"
+ "</"
+ "/>"
+] @tag.delimiter
+
+"=" @operator
diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm
new file mode 100644
index 000000000..f12a68599
--- /dev/null
+++ b/queries/html_tags/injections.scm
@@ -0,0 +1,7 @@
+((style_element
+ (raw_text) @css))
+
+((script_element
+ (raw_text) @javascript))
+
+(comment) @comment @combined
diff --git a/queries/svelte/highlights.scm b/queries/svelte/highlights.scm
index 1db90486b..058682a7c 100644
--- a/queries/svelte/highlights.scm
+++ b/queries/svelte/highlights.scm
@@ -1,43 +1,6 @@
-((element (start_tag (tag_name) @_tag) (text) @text.title)
- (#match? @_tag "^(h[0-9]|title)$"))
+; inherits: html_tags
-((element (start_tag (tag_name) @_tag) (text) @text.strong)
- (#match? @_tag "^(strong|b)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
- (#match? @_tag "^(em|i)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.strike)
- (#match? @_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)$"))
-
-((element (start_tag (tag_name) @_tag) (text) @text.uri)
- (#eq? @_tag "a"))
-
-((attribute
- (attribute_name) @_attr
- (quoted_attribute_value (attribute_value) @text.uri))
- (#match? @_attr "^(href|src)$"))
-
-(tag_name) @tag
-(attribute_name) @property
-(erroneous_end_tag_name) @error
-(comment) @comment
-
-[
- (attribute_value)
- (quoted_attribute_value)
-] @string
-
-[
- (text)
- (raw_text_expr)
-] @none
+(raw_text_expr) @none
[
(special_block_keyword)
@@ -50,13 +13,7 @@
"}"
] @punctuation.bracket
-"=" @operator
-
[
- "<"
- ">"
- "</"
- "/>"
"#"
":"
"/"
diff --git a/queries/svelte/injections.scm b/queries/svelte/injections.scm
index c57ccb759..cca623f3a 100644
--- a/queries/svelte/injections.scm
+++ b/queries/svelte/injections.scm
@@ -1,5 +1,4 @@
-((style_element
- (raw_text) @css))
+; inherits: html_tags
(
(style_element
@@ -15,10 +14,7 @@
(quoted_attribute_value (attribute_value) @css))
(#eq? @_attr "style"))
-((script_element
- (raw_text) @javascript))
-
-((raw_text_expr) @javascript)
+(raw_text_expr) @javascript
(
(script_element
diff --git a/queries/vue/highlights.scm b/queries/vue/highlights.scm
index f16c189a1..093598b74 100644
--- a/queries/vue/highlights.scm
+++ b/queries/vue/highlights.scm
@@ -1,22 +1,13 @@
+; inherits: html_tags
+
[
- (component)
(template_element)
- (start_tag)
- (tag_name)
(directive_attribute)
(directive_dynamic_argument)
(directive_dynamic_argument_value)
(component)
- (end_tag)
] @tag
-(erroneous_end_tag_name) @error
-(attribute_name) @property
-(attribute_value) @string
-(quoted_attribute_value) @string
-(comment) @comment
-
-(text) @none
(element) @string
(interpolation) @punctuation.special
(interpolation
@@ -27,12 +18,3 @@
(directive_name)
(directive_argument)
] @method
-
-"=" @operator
-
-[
- "<"
- ">"
- "</"
- "/>"
- ] @tag.delimiter
diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm
index b7e196463..490983878 100644
--- a/queries/vue/injections.scm
+++ b/queries/vue/injections.scm
@@ -1,5 +1,4 @@
-((style_element
- (raw_text) @css))
+; inherits: html_tags
(
(style_element
@@ -10,9 +9,6 @@
(#match? @_lang "(scss|postcss|less)")
)
-((script_element
- (raw_text) @javascript))
-
(
(script_element
(start_tag
@@ -25,8 +21,8 @@
((interpolation
(raw_text) @javascript))
-((directive_attribute
- (quoted_attribute_value
+((directive_attribute
+ (quoted_attribute_value
(attribute_value) @javascript)))
(comment) @comment