From a32d537d0ab61c29dca556d6ffe35431d9f4f1d1 Mon Sep 17 00:00:00 2001 From: Jaakko Paju Date: Mon, 8 Jan 2024 04:04:43 +0200 Subject: [PATCH] Add HOCON language support (#9203) * Add HOCON language support * Remove error query Co-authored-by: Michael Davis * Change include query * Fix query error --------- Co-authored-by: Michael Davis --- book/src/generated/lang-support.md | 1 + languages.toml | 12 +++++++++++ runtime/queries/hocon/highlights.scm | 31 ++++++++++++++++++++++++++++ runtime/queries/hocon/indents.scm | 10 +++++++++ 4 files changed, 54 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 0c5b35cc6..ba68e206a 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 a013dab8c..77ed0eb61 100644 --- a/languages.toml +++ b/languages.toml @@ -3013,3 +3013,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 000000000..d1aa38a27 --- /dev/null +++ b/runtime/queries/hocon/highlights.scm @@ -0,0 +1,31 @@ +(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) @keyword.directive + +[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket + +(unit) @keyword +(path (_) @keyword) +(unquoted_path "." @punctuation.delimiter) +[ "," ] @punctuation.delimiter + diff --git a/runtime/queries/hocon/indents.scm b/runtime/queries/hocon/indents.scm new file mode 100644 index 000000000..27c2c988f --- /dev/null +++ b/runtime/queries/hocon/indents.scm @@ -0,0 +1,10 @@ +[ + (object) + (array) +] @indent + +[ + "]" + "}" +] @outdent +