From cd2414b07b6bcdb97de904d8e59fb2b0310393c9 Mon Sep 17 00:00:00 2001 From: Jaakko Paju <36770267+JPaju@users.noreply.github.com> Date: Tue, 2 Jan 2024 01:19:02 +0200 Subject: [PATCH 1/4] Add HOCON language support --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++++++ runtime/queries/hocon/highlights.scm | 33 ++++++++++++++++++++++++++++ runtime/queries/hocon/indents.scm | 10 +++++++++ 4 files changed, 56 insertions(+) create mode 100644 runtime/queries/hocon/highlights.scm create mode 100644 runtime/queries/hocon/indents.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 0c5b35cc6f08..ba68e206a90b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -68,6 +68,7 @@ | haskell-persistent | ✓ | | | | | hcl | ✓ | | ✓ | `terraform-ls` | | heex | ✓ | ✓ | | `elixir-ls` | +| hocon | ✓ | | ✓ | | | hosts | ✓ | | | | | html | ✓ | | | `vscode-html-language-server` | | hurl | ✓ | | ✓ | | diff --git a/languages.toml b/languages.toml index b47fb4e2b849..2499af9c744b 100644 --- a/languages.toml +++ b/languages.toml @@ -3006,3 +3006,15 @@ file-types = ["janet"] comment-token = "#" indent = { tab-width = 2, unit = " " } grammar = "clojure" + +[[language]] +name = "hocon" +scope = "source.conf" +file-types = ["conf"] +comment-token = "#" +auto-format = true +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "hocon" +source = { git = "https://github.com/antosha417/tree-sitter-hocon", rev = "c390f10519ae69fdb03b3e5764f5592fb6924bcc" } diff --git a/runtime/queries/hocon/highlights.scm b/runtime/queries/hocon/highlights.scm new file mode 100644 index 000000000000..4a92af460b19 --- /dev/null +++ b/runtime/queries/hocon/highlights.scm @@ -0,0 +1,33 @@ +(comment) @comment + +(null) @constant.builtin +[(true) (false)] @constant.builtin.boolean +(number) @constant.numeric +(string) @string +(multiline_string) @string +(string (escape_sequence) @constant.character.escape) +(unquoted_string) @string + +(value [":" "=" "+=" ] @operator) + +(substitution (_) @string) +(substitution ["${" "${?" "}"] @punctuation.special) + +[ + "url" + "file" + "classpath" + "required" +] @function.builtin + +(include "include" @include) + +[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket + +(unit) @keyword +(path (_) @keyword) +(unquoted_path "." @punctuation.delimiter) +[ "," ] @punctuation.delimiter + +(ERROR) @error + diff --git a/runtime/queries/hocon/indents.scm b/runtime/queries/hocon/indents.scm new file mode 100644 index 000000000000..27c2c988f7ef --- /dev/null +++ b/runtime/queries/hocon/indents.scm @@ -0,0 +1,10 @@ +[ + (object) + (array) +] @indent + +[ + "]" + "}" +] @outdent + From 1133e312444b17a8fd33cffef583de7f4cc04d87 Mon Sep 17 00:00:00 2001 From: Jaakko Paju Date: Tue, 2 Jan 2024 23:55:40 +0200 Subject: [PATCH 2/4] Remove error query Co-authored-by: Michael Davis --- runtime/queries/hocon/highlights.scm | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtime/queries/hocon/highlights.scm b/runtime/queries/hocon/highlights.scm index 4a92af460b19..95163ce33a95 100644 --- a/runtime/queries/hocon/highlights.scm +++ b/runtime/queries/hocon/highlights.scm @@ -28,6 +28,3 @@ (path (_) @keyword) (unquoted_path "." @punctuation.delimiter) [ "," ] @punctuation.delimiter - -(ERROR) @error - From e312174b6fc8e46e40c7e28d9eac4f2573615f7c Mon Sep 17 00:00:00 2001 From: Jaakko Paju <36770267+JPaju@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:56:37 +0200 Subject: [PATCH 3/4] Change include query --- runtime/queries/hocon/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/hocon/highlights.scm b/runtime/queries/hocon/highlights.scm index 95163ce33a95..dc9b1674bdc6 100644 --- a/runtime/queries/hocon/highlights.scm +++ b/runtime/queries/hocon/highlights.scm @@ -20,7 +20,7 @@ "required" ] @function.builtin -(include "include" @include) +(include @keyword.control.import) [ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket From 6a58791f7aa129875d4132985d22ba2919d16eb3 Mon Sep 17 00:00:00 2001 From: Jaakko Paju <36770267+JPaju@users.noreply.github.com> Date: Wed, 3 Jan 2024 01:57:54 +0200 Subject: [PATCH 4/4] Fix query error --- runtime/queries/hocon/highlights.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/queries/hocon/highlights.scm b/runtime/queries/hocon/highlights.scm index dc9b1674bdc6..d1aa38a27dbc 100644 --- a/runtime/queries/hocon/highlights.scm +++ b/runtime/queries/hocon/highlights.scm @@ -20,7 +20,7 @@ "required" ] @function.builtin -(include @keyword.control.import) +(include) @keyword.directive [ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket @@ -28,3 +28,4 @@ (path (_) @keyword) (unquoted_path "." @punctuation.delimiter) [ "," ] @punctuation.delimiter +