From 00da7a196561080bd5a91e2dedd5bc671f067463 Mon Sep 17 00:00:00 2001 From: greym0uth Date: Wed, 26 Oct 2022 17:20:20 -0700 Subject: [PATCH 1/3] feat(lang): add kdl grammar --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++++++++ runtime/queries/kdl/highlights.scm | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 runtime/queries/kdl/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index caf5d525b16b..fa565b0daeb1 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -60,6 +60,7 @@ | jsonnet | ✓ | | | `jsonnet-language-server` | | jsx | ✓ | ✓ | ✓ | `typescript-language-server` | | julia | ✓ | | | `julia` | +| kdl | ✓ | | | | | kotlin | ✓ | | | `kotlin-language-server` | | latex | ✓ | ✓ | | `texlab` | | lean | ✓ | | | `lean` | diff --git a/languages.toml b/languages.toml index 6f58112a825a..fa2d6b71ad3c 100644 --- a/languages.toml +++ b/languages.toml @@ -1849,3 +1849,15 @@ formatter = { command = "dfmt" } [[grammar]] name = "d" source = { git = "https://github.com/gdamore/tree-sitter-d", rev="601c4a1e8310fb2f3c43fa8a923d0d27497f3c04" } + +[[language]] +name = "kdl" +scope = "source.kdl" +file-types = ["kdl"] +roots = [] +comment-token = "//" +injection-regex = "kdl" + +[[grammar]] +name = "kdl" +source = { git = "https://github.com/Unoqwy/tree-sitter-kdl", rev = "e1cd292c6d15df6610484e1d4b5c987ecad52373" } diff --git a/runtime/queries/kdl/highlights.scm b/runtime/queries/kdl/highlights.scm new file mode 100644 index 000000000000..842666f8ccaa --- /dev/null +++ b/runtime/queries/kdl/highlights.scm @@ -0,0 +1,22 @@ +(comment) @comment +(single_line_comment) @comment + +(node + name: (identifier) @function) +(prop (identifier) @property) +(type) @type + +(bare_identifier) @variable.other.member + +(keyword) @keyword + +(string) @string +(number) @number +(boolean) @constant.builtin.boolean + +"." @punctuation.delimiter + +"=" @operator + +"{" @punctuation.bracket +"}" @punctuation.bracket From 07b83026dc12420cdc8bf893143f775f762a9ee2 Mon Sep 17 00:00:00 2001 From: Jaden Date: Fri, 28 Oct 2022 13:06:06 -0700 Subject: [PATCH 2/3] use @constant.numeric for number Co-authored-by: Michael Davis --- runtime/queries/kdl/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/kdl/highlights.scm b/runtime/queries/kdl/highlights.scm index 842666f8ccaa..f8505e78dae7 100644 --- a/runtime/queries/kdl/highlights.scm +++ b/runtime/queries/kdl/highlights.scm @@ -11,7 +11,7 @@ (keyword) @keyword (string) @string -(number) @number +(number) @constant.numeric (boolean) @constant.builtin.boolean "." @punctuation.delimiter From 259afd0f6f4eae0c26e119d0deb5bf644fb080a3 Mon Sep 17 00:00:00 2001 From: Jaden Date: Fri, 28 Oct 2022 13:06:25 -0700 Subject: [PATCH 3/3] user @attribute for identifiers Co-authored-by: Michael Davis --- runtime/queries/kdl/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/kdl/highlights.scm b/runtime/queries/kdl/highlights.scm index f8505e78dae7..d83bde19ceed 100644 --- a/runtime/queries/kdl/highlights.scm +++ b/runtime/queries/kdl/highlights.scm @@ -3,7 +3,7 @@ (node name: (identifier) @function) -(prop (identifier) @property) +(prop (identifier) @attribute) (type) @type (bare_identifier) @variable.other.member