From fa315064637ee91841c61787b44576579f71a14f Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 19 Mar 2023 22:00:32 +0100 Subject: [PATCH 1/7] Add initial Smithy support --- book/src/generated/lang-support.md | 1 + languages.toml | 16 ++++ runtime/queries/smithy/highlights.scm | 102 ++++++++++++++++++++++++++ runtime/queries/smithy/injections.scm | 3 + 4 files changed, 122 insertions(+) create mode 100644 runtime/queries/smithy/highlights.scm create mode 100644 runtime/queries/smithy/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index f62b147fec45..3c18956ae423 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -123,6 +123,7 @@ | scheme | ✓ | | | | | scss | ✓ | | | `vscode-css-language-server` | | slint | ✓ | | ✓ | `slint-lsp` | +| smithy | ✓ | | | `cs` | | sml | ✓ | | | | | solidity | ✓ | | | `solc` | | sql | ✓ | | | | diff --git a/languages.toml b/languages.toml index 73114a193f30..37ba9c1a986a 100644 --- a/languages.toml +++ b/languages.toml @@ -2341,3 +2341,19 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "capnp" source = { git = "https://github.com/amaanq/tree-sitter-capnp", rev = "fc6e2addf103861b9b3dffb82c543eb6b71061aa" } + +[[language]] +name = "smithy" +scope = "source.smithy" +injection-regex = "smithy" +file-types = ["smithy"] +shebangs = [] +roots = ["smithy-build.json"] +auto-format = false +comment-token = "//" +indent = { tab-width = 4, unit = " " } +language-server = { command = "cs", args = ["launch", "com.disneystreaming.smithy:smithy-language-server:0.0.21", "--", "0"] } + +[[grammar]] +name = "smithy" +source = { git = "https://github.com/indoorvivants/tree-sitter-smithy", rev = "cf8c7eb9faf7c7049839585eac19c94af231e6a0" } diff --git a/runtime/queries/smithy/highlights.scm b/runtime/queries/smithy/highlights.scm new file mode 100644 index 000000000000..318c48f83225 --- /dev/null +++ b/runtime/queries/smithy/highlights.scm @@ -0,0 +1,102 @@ +; Queries are taken from: https://github.com/indoorvivants/tree-sitter-smithy/blob/main/queries/highlights.scm +; Preproc +(control_key) @preproc + +; Namespace +(namespace) @namespace + +; Includes +[ + "use" +] @include + +; Builtins +(primitive) @type.builtin +[ + "enum" + "intEnum" + "list" + "map" + "set" +] @type.builtin + +; Fields (Members) +; (field) @field + +(key_identifier) @field +(shape_member + (field) @field) +(operation_field) @field +(operation_error_field) @field + +; Constants +(enum_member + (enum_field) @constant) + +; Types +(identifier) @type +(structure_resource + (shape_id) @type) + +; Attributes +(mixins + (shape_id) @attribute) +(trait_statement + (shape_id (#set! "priority" 105)) @attribute) + +; Operators +[ + "@" + "-" + "=" + ":=" +] @operator + +; Keywords +[ + "namespace" + "service" + "structure" + "operation" + "union" + "resource" + "metadata" + "apply" + "for" + "with" +] @keyword + +; Literals +(string) @string +(escape_sequence) @string.escape + +(number) @number + +(float) @float + +(boolean) @boolean + +(null) @constant.builtin + +; Misc +[ + "$" + "#" +] @punctuation.special + +["{" "}"] @punctuation.bracket + +["(" ")"] @punctuation.bracket + +["[" "]"] @punctuation.bracket + +[ + ":" + "." +] @punctuation.delimiter + +; Comments +[ + (comment) + (documentation_comment) +] @comment @spell diff --git a/runtime/queries/smithy/injections.scm b/runtime/queries/smithy/injections.scm new file mode 100644 index 000000000000..ce75fc4d9874 --- /dev/null +++ b/runtime/queries/smithy/injections.scm @@ -0,0 +1,3 @@ +(block parameter: (expr) @injection.language + (contents) @injection.content + (#set! injection.include-children)) From 0a29e29b628d2795e4bafdc77e624eb24c919f03 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 19 Mar 2023 22:38:09 +0100 Subject: [PATCH 2/7] Smithy actually does not need injections.scm --- runtime/queries/smithy/injections.scm | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 runtime/queries/smithy/injections.scm diff --git a/runtime/queries/smithy/injections.scm b/runtime/queries/smithy/injections.scm deleted file mode 100644 index ce75fc4d9874..000000000000 --- a/runtime/queries/smithy/injections.scm +++ /dev/null @@ -1,3 +0,0 @@ -(block parameter: (expr) @injection.language - (contents) @injection.content - (#set! injection.include-children)) From aa451e7e90d5b69a47afdf529c877b939750c88a Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 20 Mar 2023 20:00:29 +0100 Subject: [PATCH 3/7] Grab latest LSP release --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 37ba9c1a986a..3eeed58ee1e5 100644 --- a/languages.toml +++ b/languages.toml @@ -2352,7 +2352,7 @@ roots = ["smithy-build.json"] auto-format = false comment-token = "//" indent = { tab-width = 4, unit = " " } -language-server = { command = "cs", args = ["launch", "com.disneystreaming.smithy:smithy-language-server:0.0.21", "--", "0"] } +language-server = { command = "cs", args = ["launch", "com.disneystreaming.smithy:smithy-language-server:latest.release", "--", "0"] } [[grammar]] name = "smithy" From 91a7378f52692066659d9652583a9345dae6e5a1 Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 20 Mar 2023 20:09:28 +0100 Subject: [PATCH 4/7] Update highlights.scm for Smithy --- runtime/queries/smithy/highlights.scm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/queries/smithy/highlights.scm b/runtime/queries/smithy/highlights.scm index 318c48f83225..d390f3aeb956 100644 --- a/runtime/queries/smithy/highlights.scm +++ b/runtime/queries/smithy/highlights.scm @@ -1,6 +1,6 @@ ; Queries are taken from: https://github.com/indoorvivants/tree-sitter-smithy/blob/main/queries/highlights.scm ; Preproc -(control_key) @preproc +(control_key) @keyword.directive ; Namespace (namespace) @namespace @@ -21,13 +21,13 @@ ] @type.builtin ; Fields (Members) -; (field) @field +; (field) @variable.other.member -(key_identifier) @field +(key_identifier) @variable.other.member (shape_member - (field) @field) -(operation_field) @field -(operation_error_field) @field + (field) @variable.other.member) +(operation_field) @variable.other.member +(operation_error_field) @variable.other.member ; Constants (enum_member @@ -42,7 +42,7 @@ (mixins (shape_id) @attribute) (trait_statement - (shape_id (#set! "priority" 105)) @attribute) + (shape_id @attribute) ; Operators [ @@ -68,13 +68,13 @@ ; Literals (string) @string -(escape_sequence) @string.escape +(escape_sequence) @constant.character.escape (number) @number (float) @float -(boolean) @boolean +(boolean) @constant.builtin.boolean (null) @constant.builtin @@ -99,4 +99,4 @@ [ (comment) (documentation_comment) -] @comment @spell +] @comment From 591b2bf0de24b897c21587d8265299c4fbc39a72 Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 20 Mar 2023 20:16:10 +0100 Subject: [PATCH 5/7] Fix missing parenthesis for Smithy highlights.scm --- runtime/queries/smithy/highlights.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/queries/smithy/highlights.scm b/runtime/queries/smithy/highlights.scm index d390f3aeb956..5f7ea20ba631 100644 --- a/runtime/queries/smithy/highlights.scm +++ b/runtime/queries/smithy/highlights.scm @@ -31,7 +31,7 @@ ; Constants (enum_member - (enum_field) @constant) + (enum_field) @type.enum) ; Types (identifier) @type @@ -42,7 +42,7 @@ (mixins (shape_id) @attribute) (trait_statement - (shape_id @attribute) + (shape_id @attribute)) ; Operators [ @@ -70,9 +70,9 @@ (string) @string (escape_sequence) @constant.character.escape -(number) @number +(number) @constant.numeric -(float) @float +(float) @constant.numeric.float (boolean) @constant.builtin.boolean From 8962b677cbf80c74474ca3edfba369d1bcb5659b Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 20 Mar 2023 20:26:29 +0100 Subject: [PATCH 6/7] Attempt #2 at fixing highlights for Smithy --- runtime/queries/smithy/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/smithy/highlights.scm b/runtime/queries/smithy/highlights.scm index 5f7ea20ba631..6a04fd1fb381 100644 --- a/runtime/queries/smithy/highlights.scm +++ b/runtime/queries/smithy/highlights.scm @@ -42,7 +42,7 @@ (mixins (shape_id) @attribute) (trait_statement - (shape_id @attribute)) + (shape_id) @attribute) ; Operators [ From 128b686ce6fe42a7dace9f07ad8108f2ee43ad50 Mon Sep 17 00:00:00 2001 From: zetashift Date: Tue, 21 Mar 2023 20:33:40 +0100 Subject: [PATCH 7/7] Fixup smithy languages.toml config and use correct import query for highlights.scm --- languages.toml | 4 +--- runtime/queries/smithy/highlights.scm | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/languages.toml b/languages.toml index 3eeed58ee1e5..d9b591f56ba2 100644 --- a/languages.toml +++ b/languages.toml @@ -2347,11 +2347,9 @@ name = "smithy" scope = "source.smithy" injection-regex = "smithy" file-types = ["smithy"] -shebangs = [] roots = ["smithy-build.json"] -auto-format = false comment-token = "//" -indent = { tab-width = 4, unit = " " } +indent = { tab-width = 4, unit = " " } language-server = { command = "cs", args = ["launch", "com.disneystreaming.smithy:smithy-language-server:latest.release", "--", "0"] } [[grammar]] diff --git a/runtime/queries/smithy/highlights.scm b/runtime/queries/smithy/highlights.scm index 6a04fd1fb381..269e96094020 100644 --- a/runtime/queries/smithy/highlights.scm +++ b/runtime/queries/smithy/highlights.scm @@ -8,7 +8,7 @@ ; Includes [ "use" -] @include +] @keyword.control.import ; Builtins (primitive) @type.builtin