From d186a9e95a478fa60e1bef86790c8787e7440d0e Mon Sep 17 00:00:00 2001 From: Jacob Pfeifer Date: Tue, 11 Jul 2023 02:18:26 -0400 Subject: feat: add Hurl Co-authored-by: Amaan Qureshi Co-authored-by: Pham Huy Hoang --------- Co-authored-by: Amaan Qureshi Co-authored-by: Pham Huy Hoang --- lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 8 +++ queries/hurl/folds.scm | 20 ++++++ queries/hurl/highlights.scm | 133 ++++++++++++++++++++++++++++++++++++++++ queries/hurl/indents.scm | 14 +++++ queries/hurl/injections.scm | 7 +++ scripts/minimal_init.lua | 1 + 7 files changed, 186 insertions(+) create mode 100644 queries/hurl/folds.scm create mode 100644 queries/hurl/highlights.scm create mode 100644 queries/hurl/indents.scm create mode 100644 queries/hurl/injections.scm diff --git a/lockfile.json b/lockfile.json index 00dca9132..48265531e 100644 --- a/lockfile.json +++ b/lockfile.json @@ -236,6 +236,9 @@ "http": { "revision": "6824a247d1326079aab4fa9f9164e9319678081d" }, + "hurl": { + "revision": "0eca909c8338364992e04c4862ac6afc5342cbb8" + }, "ini": { "revision": "1a0ce072ebf3afac7d5603d9a95bb7c9a6709b44" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index ed8e5718d..a9e2f48c8 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -737,6 +737,14 @@ list.http = { maintainers = { "@amaanq" }, } +list.hurl = { + install_info = { + url = "https://github.com/pfeiferj/tree-sitter-hurl", + files = { "src/parser.c" }, + }, + maintainers = { "@pfeiferj" }, +} + list.ini = { install_info = { url = "https://github.com/justinmk/tree-sitter-ini", diff --git a/queries/hurl/folds.scm b/queries/hurl/folds.scm new file mode 100644 index 000000000..d7b8cd6cd --- /dev/null +++ b/queries/hurl/folds.scm @@ -0,0 +1,20 @@ +; fold.scm + +[ + (comment) + (entry) + (request) + (response) + (header) + (request_section) + (body) + (response_section) + (multipart_form_data_section) + (cookies_section) + (captures_section) + (asserts_section) + (options_section) + (basic_auth_section) + (json_object) + (json_array) +] @fold diff --git a/queries/hurl/highlights.scm b/queries/hurl/highlights.scm new file mode 100644 index 000000000..a32f1965b --- /dev/null +++ b/queries/hurl/highlights.scm @@ -0,0 +1,133 @@ +; highlights.scm + +[ + "[QueryStringParams]" + "[FormParams]" + "[MultipartFormData]" + "[Cookies]" + "[Captures]" + "[Asserts]" + "[Options]" + "[BasicAuth]" + (key_string) + (json_key_string) +] @property + +[ + "\\" + (regex_escaped_char) + (quoted_string_escaped_char) + (key_string_escaped_char) + (value_string_escaped_char) + (oneline_string_escaped_char) + (multiline_string_escaped_char) + (filename_escaped_char) + (json_string_escaped_char) +] @string.escape + +[ + "status" + "url" + "header" + "cookie" + "body" + "xpath" + "jsonpath" + "regex" + "variable" + "duration" + "sha256" + "md5" + "bytes" +] @function.builtin + +[ + "null" + "cacert" + "compressed" + "location" + "insecure" + "path-as-is" + "proxy" + "max-redirs" + "retry" + "retry-interval" + "retry-max-count" + (variable_option "variable") + "verbose" + "very-verbose" +] @constant.builtin + +(boolean) @boolean + +(variable_name) @variable + +[ + "not" + "equals" + "notEquals" + "greaterThan" + "greaterThanOrEquals" + "lessThan" + "lessThanOrEquals" + "startsWith" + "endsWith" + "contains" + "matches" + "exists" + "includes" + "isInteger" + "isFloat" + "isBoolean" + "isString" + "isCollection" +] @keyword.operator + +[ + "==" + "!=" + ">" + ">=" + "<" + "<=" +] @operator + +[ + (integer) + (status) +] @number + +[ + (float) + (json_number) +] @float + +[ ":" "," ] @punctuation.delimiter + +[ "[" "]" "{" "}" "{{" "}}" ] @punctuation.bracket + +[ + (value_string) + (quoted_string) + (json_string) +] @string + + +[ + "base64," + "file," + "hex," + (file_value) + (version) +] @string.special + +(regex) @string.regex + +(multiline_string_type) @type + +(comment) @comment @spell + +(filter) @attribute + +(method) @type.builtin + diff --git a/queries/hurl/indents.scm b/queries/hurl/indents.scm new file mode 100644 index 000000000..232cfc01a --- /dev/null +++ b/queries/hurl/indents.scm @@ -0,0 +1,14 @@ +; indents.scm + +[ + (json_object) + (json_array) +] @indent.begin + +[ + "}" + "]" +] @indent.branch + +(xml_tag) @indent.begin +(xml_close_tag) @indent.branch diff --git a/queries/hurl/injections.scm b/queries/hurl/injections.scm new file mode 100644 index 000000000..933633e03 --- /dev/null +++ b/queries/hurl/injections.scm @@ -0,0 +1,7 @@ +; injections.scm +(json_value) @json +(xml) @html + +(multiline_string + (multiline_string_type) @language + (multiline_string_content) @content) diff --git a/scripts/minimal_init.lua b/scripts/minimal_init.lua index e650a0dd8..f7a7ee590 100644 --- a/scripts/minimal_init.lua +++ b/scripts/minimal_init.lua @@ -6,6 +6,7 @@ vim.filetype.add { extension = { conf = "hocon", cmm = "t32", + hurl = "hurl", ncl = "nickel", tig = "tiger", usd = "usd", -- cgit v1.2.3-70-g09d2