aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/svelte
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/svelte
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/svelte')
-rw-r--r--runtime/queries/svelte/folds.scm13
-rw-r--r--runtime/queries/svelte/highlights.scm43
-rw-r--r--runtime/queries/svelte/indents.scm34
-rw-r--r--runtime/queries/svelte/injections.scm47
-rw-r--r--runtime/queries/svelte/locals.scm1
5 files changed, 138 insertions, 0 deletions
diff --git a/runtime/queries/svelte/folds.scm b/runtime/queries/svelte/folds.scm
new file mode 100644
index 000000000..6440301af
--- /dev/null
+++ b/runtime/queries/svelte/folds.scm
@@ -0,0 +1,13 @@
+; inherits: html
+
+[
+ (if_statement)
+ (else_if_block)
+ (else_block)
+ (each_statement)
+ (await_statement)
+ (then_block)
+ (catch_block)
+ (key_statement)
+ (snippet_statement)
+] @fold
diff --git a/runtime/queries/svelte/highlights.scm b/runtime/queries/svelte/highlights.scm
new file mode 100644
index 000000000..dc98290dd
--- /dev/null
+++ b/runtime/queries/svelte/highlights.scm
@@ -0,0 +1,43 @@
+; inherits: html
+
+(raw_text) @none
+
+[
+ "as"
+ "key"
+ "html"
+ "snippet"
+ "render"
+] @keyword
+
+"const" @keyword.modifier
+
+[
+ "if"
+ "else if"
+ "else"
+ "then"
+] @keyword.conditional
+
+"each" @keyword.repeat
+
+[
+ "await"
+ "then"
+] @keyword.coroutine
+
+"catch" @keyword.exception
+
+"debug" @keyword.debug
+
+[
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "#"
+ ":"
+ "/"
+ "@"
+] @tag.delimiter
diff --git a/runtime/queries/svelte/indents.scm b/runtime/queries/svelte/indents.scm
new file mode 100644
index 000000000..0c67647d7
--- /dev/null
+++ b/runtime/queries/svelte/indents.scm
@@ -0,0 +1,34 @@
+; inherits: html
+
+[
+ (if_statement)
+ (each_statement)
+ (await_statement)
+ (key_statement)
+ (snippet_statement)
+] @indent.begin
+
+(if_end
+ "}" @indent.end)
+
+(each_end
+ "}" @indent.end)
+
+(await_end
+ "}" @indent.end)
+
+(key_end
+ "}" @indent.end)
+
+(snippet_end
+ "}" @indent.end)
+
+[
+ (if_end)
+ (else_if_block)
+ (else_block)
+ (each_end)
+ (await_end)
+ (key_end)
+ (snippet_end)
+] @indent.branch
diff --git a/runtime/queries/svelte/injections.scm b/runtime/queries/svelte/injections.scm
new file mode 100644
index 000000000..f20ae66c8
--- /dev/null
+++ b/runtime/queries/svelte/injections.scm
@@ -0,0 +1,47 @@
+; inherits: html_tags
+
+((style_element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (quoted_attribute_value
+ (attribute_value) @_lang)))
+ (raw_text) @injection.content)
+ (#eq? @_attr "lang")
+ (#any-of? @_lang "scss" "postcss" "less")
+ (#set! injection.language "scss"))
+
+((svelte_raw_text) @injection.content
+ (#set! injection.language "javascript"))
+
+((script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (quoted_attribute_value
+ (attribute_value) @_lang)))
+ (raw_text) @injection.content)
+ (#eq? @_attr "lang")
+ (#any-of? @_lang "ts" "typescript")
+ (#set! injection.language "typescript"))
+
+((script_element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (quoted_attribute_value
+ (attribute_value) @_lang)))
+ (raw_text) @injection.content)
+ (#eq? @_attr "lang")
+ (#any-of? @_lang "js" "javascript")
+ (#set! injection.language "javascript"))
+
+((element
+ (start_tag
+ (attribute
+ (attribute_name) @_attr
+ (quoted_attribute_value
+ (attribute_value) @injection.language)))
+ (text) @injection.content)
+ (#eq? @_attr "lang")
+ (#eq? @injection.language "pug"))
diff --git a/runtime/queries/svelte/locals.scm b/runtime/queries/svelte/locals.scm
new file mode 100644
index 000000000..1f2129cf9
--- /dev/null
+++ b/runtime/queries/svelte/locals.scm
@@ -0,0 +1 @@
+; inherits: html