aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/http
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/http
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/http')
-rw-r--r--runtime/queries/http/folds.scm5
-rw-r--r--runtime/queries/http/highlights.scm64
-rw-r--r--runtime/queries/http/injections.scm24
3 files changed, 93 insertions, 0 deletions
diff --git a/runtime/queries/http/folds.scm b/runtime/queries/http/folds.scm
new file mode 100644
index 000000000..f7108a551
--- /dev/null
+++ b/runtime/queries/http/folds.scm
@@ -0,0 +1,5 @@
+[
+ (section)
+ (json_body)
+ (variable_declaration)+
+] @fold
diff --git a/runtime/queries/http/highlights.scm b/runtime/queries/http/highlights.scm
new file mode 100644
index 000000000..1ac243729
--- /dev/null
+++ b/runtime/queries/http/highlights.scm
@@ -0,0 +1,64 @@
+; Methods
+(method) @function.method
+
+; Headers
+(header
+ name: (_) @constant)
+
+(header
+ value: (_) @string)
+
+; Variables
+(identifier) @variable
+
+(variable_declaration
+ "@" @character.special)
+
+(variable_declaration
+ (value) @string)
+
+; Operators
+(comment
+ "=" @operator)
+
+(variable_declaration
+ "=" @operator)
+
+; keywords
+(comment
+ "@" @keyword
+ name: (_) @keyword)
+
+; Literals
+(request
+ url: (_) @string.special.url)
+
+(http_version) @string.special
+
+; Response
+(status_code) @number
+
+(status_text) @string
+
+; Punctuation
+[
+ "{{"
+ "}}"
+ "{%"
+ "%}"
+] @punctuation.bracket
+
+">" @punctuation.special
+
+(header
+ ":" @punctuation.delimiter)
+
+; external JSON body
+(external_body
+ path: (_) @string.special.path)
+
+; Comments
+[
+ (comment)
+ (request_separator)
+] @comment @spell
diff --git a/runtime/queries/http/injections.scm b/runtime/queries/http/injections.scm
new file mode 100644
index 000000000..f0e086580
--- /dev/null
+++ b/runtime/queries/http/injections.scm
@@ -0,0 +1,24 @@
+; Comments
+((comment) @injection.content
+ (#set! injection.language "comment"))
+
+; Body
+((json_body) @injection.content
+ (#set! injection.language "json"))
+
+((xml_body) @injection.content
+ (#set! injection.language "xml"))
+
+((graphql_data) @injection.content
+ (#set! injection.language "graphql"))
+
+; Script (default to javascript)
+((comment
+ name: (_) @_name
+ (#eq? @_name "lang")
+ value: (_) @injection.language)?
+ .
+ (_
+ (script) @injection.content
+ (#offset! @injection.content 0 2 0 -2))
+ (#set! injection.language "javascript"))