aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/vue
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/vue
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/vue')
-rw-r--r--runtime/queries/vue/folds.scm6
-rw-r--r--runtime/queries/vue/highlights.scm43
-rw-r--r--runtime/queries/vue/indents.scm7
-rw-r--r--runtime/queries/vue/injections.scm77
4 files changed, 133 insertions, 0 deletions
diff --git a/runtime/queries/vue/folds.scm b/runtime/queries/vue/folds.scm
new file mode 100644
index 000000000..314256e4e
--- /dev/null
+++ b/runtime/queries/vue/folds.scm
@@ -0,0 +1,6 @@
+[
+ (element)
+ (template_element)
+ (script_element)
+ (style_element)
+] @fold
diff --git a/runtime/queries/vue/highlights.scm b/runtime/queries/vue/highlights.scm
new file mode 100644
index 000000000..64195c346
--- /dev/null
+++ b/runtime/queries/vue/highlights.scm
@@ -0,0 +1,43 @@
+; inherits: html_tags
+
+[
+ "["
+ "]"
+] @punctuation.bracket
+
+(interpolation) @punctuation.special
+
+(interpolation
+ (raw_text) @none)
+
+(dynamic_directive_inner_value) @variable
+
+(directive_name) @tag.attribute
+
+; Accessing a component object's field
+(":"
+ .
+ (directive_value) @variable.member)
+
+("."
+ .
+ (directive_value) @property)
+
+; @click is like onclick for HTML
+("@"
+ .
+ (directive_value) @function.method)
+
+; Used in v-slot, declaring position the element should be put in
+("#"
+ .
+ (directive_value) @variable)
+
+(directive_attribute
+ (quoted_attribute_value) @punctuation.special)
+
+(directive_attribute
+ (quoted_attribute_value
+ (attribute_value) @none))
+
+(directive_modifier) @function.method
diff --git a/runtime/queries/vue/indents.scm b/runtime/queries/vue/indents.scm
new file mode 100644
index 000000000..6b377f323
--- /dev/null
+++ b/runtime/queries/vue/indents.scm
@@ -0,0 +1,7 @@
+; inherits: html_tags
+
+(template_element) @indent.begin
+
+(template_element
+ (end_tag
+ ">" @indent.end) @indent.branch)
diff --git a/runtime/queries/vue/injections.scm b/runtime/queries/vue/injections.scm
new file mode 100644
index 000000000..586964011
--- /dev/null
+++ b/runtime/queries/vue/injections.scm
@@ -0,0 +1,77 @@
+; inherits html_tags
+; <script lang="css">
+((style_element
+ (start_tag
+ (attribute
+ (attribute_name) @_lang
+ (quoted_attribute_value
+ (attribute_value) @injection.language)))
+ (raw_text) @injection.content)
+ (#eq? @_lang "lang")
+ (#any-of? @injection.language "css" "scss"))
+
+; TODO: When nvim-treesitter has postcss and less parsers, use @injection.language and @injection.content instead
+; <script lang="scss">
+(style_element
+ (start_tag
+ (attribute
+ (attribute_name) @_lang
+ (quoted_attribute_value
+ (attribute_value) @_scss)))
+ (raw_text) @injection.content
+ (#eq? @_lang "lang")
+ (#any-of? @_scss "less" "postcss" "sass")
+ (#set! injection.language "scss"))
+
+; <script lang="js">
+((script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_lang
+ (quoted_attribute_value
+ (attribute_value) @_js)))
+ (raw_text) @injection.content)
+ (#eq? @_lang "lang")
+ (#eq? @_js "js")
+ (#set! injection.language "javascript"))
+
+; <script lang="ts">
+((script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_lang
+ (quoted_attribute_value
+ (attribute_value) @_ts)))
+ (raw_text) @injection.content)
+ (#eq? @_lang "lang")
+ (#eq? @_ts "ts")
+ (#set! injection.language "typescript"))
+
+; <script lang="tsx">
+; <script lang="jsx">
+(script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (quoted_attribute_value
+ (attribute_value) @injection.language)))
+ (#eq? @_attr "lang")
+ (#any-of? @injection.language "tsx" "jsx")
+ (raw_text) @injection.content)
+
+((interpolation
+ (raw_text) @injection.content)
+ (#set! injection.language "typescript"))
+
+(directive_attribute
+ (quoted_attribute_value
+ (attribute_value) @injection.content
+ (#set! injection.language "typescript")))
+
+(template_element
+ (start_tag
+ (attribute
+ (quoted_attribute_value
+ (attribute_value) @injection.language)))
+ (text) @injection.content
+ (#eq? @injection.language "pug"))