From 0fd6d324828952eaa4596d0d3d8043acc401bc05 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Wed, 21 Aug 2024 03:08:45 -0400 Subject: [PATCH] feat(http): switch to new parser version (#7063) --- lockfile.json | 2 +- queries/http/highlights.scm | 56 +++++++++++++++---------------------- queries/http/injections.scm | 19 ++++++++++--- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/lockfile.json b/lockfile.json index 5b2c03796..d4301beed 100644 --- a/lockfile.json +++ b/lockfile.json @@ -315,7 +315,7 @@ "revision": "ea71012d3fe14dd0b69f36be4f96bdfe9155ebae" }, "http": { - "revision": "5ae6c7cfa62a7d7325c26171a1de4f6b866702b5" + "revision": "b88cd0c7dba0128b8f28fcb25cca13eea0d193b3" }, "hurl": { "revision": "fba6ed8db3a009b9e7d656511931b181a3ee5b08" diff --git a/queries/http/highlights.scm b/queries/http/highlights.scm index efa77d27e..76d62778c 100644 --- a/queries/http/highlights.scm +++ b/queries/http/highlights.scm @@ -1,50 +1,36 @@ -; Keywords -(scheme) @module - ; Methods (method) @function.method ; Headers (header - name: (name) @constant) + name: (_) @constant) ; Variables (variable_declaration name: (identifier) @variable) -; Fields -(pair - name: (identifier) @variable.member) - -; URL / Host -(host) @string.special.url - -(path - (identifier) @string.special.url) - -; Parameters -(query_param - (key) @variable.parameter) - ; Operators -[ - "=" - "?" - "&" - "@" - "<" -] @operator +(comment + "=" @operator) + +(variable_declaration + "=" @operator) + +; keywords +(comment + "@" @keyword + name: (_) @keyword) ; Literals -(target_url) @string.special.url +(request + url: (_) @string.special.url) (http_version) @constant -(string) @string +; Response +(status_code) @number -(number) @number - -(boolean) @boolean +(status_text) @string ; Punctuation [ @@ -52,11 +38,15 @@ "}}" ] @punctuation.bracket -":" @punctuation.delimiter +(header + ":" @punctuation.delimiter) ; external JSON body (external_body - file_path: (path) @string.special.path) + path: (_) @string.special.path) ; Comments -(comment) @comment @spell +[ + (comment) + (request_separator) +] @comment @spell diff --git a/queries/http/injections.scm b/queries/http/injections.scm index 68268afcb..0eebd0fae 100644 --- a/queries/http/injections.scm +++ b/queries/http/injections.scm @@ -9,9 +9,20 @@ ((xml_body) @injection.content (#set! injection.language "xml")) -((graphql_body) @injection.content +((graphql_data) @injection.content (#set! injection.language "graphql")) -; Lua scripting -((script_variable) @injection.content - (#set! injection.language "lua")) +; Script (default to javascript) +((script) @injection.content + (#offset! @injection.content 0 2 0 -2) + (#set! injection.language "javascript")) + +; Script with other languages +((comment + name: (_) @_name + (#eq? @_name "lang") + value: (_) @injection.language) + . + (_ + (script) @injection.content + (#offset! @injection.content 0 2 0 -2)))