on master help sign in
Add initial Smithy support (#6370)
commit0e0c16e6fa2610c02a4fa6a3f9f90ba5e32133bb authorzetashift <rskaraya@gmail.com> dateTue 21 Mar 2023, 23:12 (4 years ago) parentb0ceac6
3 files changed+117
book/src/generated/lang-support.md+1 languages.toml+14 runtime/queries/smithy/highlights.scm+102
book/src/generated/lang-support.md+1
@@ -123,6 +123,7 @@
123123| scheme | ✓ | | | |
124124| scss | ✓ | | | `vscode-css-language-server` |
125125| slint | ✓ | | ✓ | `slint-lsp` |
126+| smithy | ✓ | | | `cs` |
126127| sml | ✓ | | | |
127128| solidity | ✓ | | | `solc` |
128129| sql | ✓ | | | |
languages.toml+14
@@ -2355,3 +2355,17 @@ indent = { tab-width = 2, unit = " " }
23552355[[grammar]]
23562356name = "capnp"
23572357source = { git = "https://github.com/amaanq/tree-sitter-capnp", rev = "fc6e2addf103861b9b3dffb82c543eb6b71061aa" }
2358+
2359+[[language]]
2360+name = "smithy"
2361+scope = "source.smithy"
2362+injection-regex = "smithy"
2363+file-types = ["smithy"]
2364+roots = ["smithy-build.json"]
2365+comment-token = "//"
2366+indent = { tab-width = 4, unit = " " }
2367+language-server = { command = "cs", args = ["launch", "com.disneystreaming.smithy:smithy-language-server:latest.release", "--", "0"] }
2368+
2369+[[grammar]]
2370+name = "smithy"
2371+source = { git = "https://github.com/indoorvivants/tree-sitter-smithy", rev = "cf8c7eb9faf7c7049839585eac19c94af231e6a0" }
runtime/queries/smithy/highlights.scmnew file+102
@@ -0,0 +1,102 @@
1+; Queries are taken from: https://github.com/indoorvivants/tree-sitter-smithy/blob/main/queries/highlights.scm
2+; Preproc
3+(control_key) @keyword.directive
4+
5+; Namespace
6+(namespace) @namespace
7+
8+; Includes
9+[
10+ "use"
11+] @keyword.control.import
12+
13+; Builtins
14+(primitive) @type.builtin
15+[
16+ "enum"
17+ "intEnum"
18+ "list"
19+ "map"
20+ "set"
21+] @type.builtin
22+
23+; Fields (Members)
24+; (field) @variable.other.member
25+
26+(key_identifier) @variable.other.member
27+(shape_member
28+ (field) @variable.other.member)
29+(operation_field) @variable.other.member
30+(operation_error_field) @variable.other.member
31+
32+; Constants
33+(enum_member
34+ (enum_field) @type.enum)
35+
36+; Types
37+(identifier) @type
38+(structure_resource
39+ (shape_id) @type)
40+
41+; Attributes
42+(mixins
43+ (shape_id) @attribute)
44+(trait_statement
45+ (shape_id) @attribute)
46+
47+; Operators
48+[
49+ "@"
50+ "-"
51+ "="
52+ ":="
53+] @operator
54+
55+; Keywords
56+[
57+ "namespace"
58+ "service"
59+ "structure"
60+ "operation"
61+ "union"
62+ "resource"
63+ "metadata"
64+ "apply"
65+ "for"
66+ "with"
67+] @keyword
68+
69+; Literals
70+(string) @string
71+(escape_sequence) @constant.character.escape
72+
73+(number) @constant.numeric
74+
75+(float) @constant.numeric.float
76+
77+(boolean) @constant.builtin.boolean
78+
79+(null) @constant.builtin
80+
81+; Misc
82+[
83+ "$"
84+ "#"
85+] @punctuation.special
86+
87+["{" "}"] @punctuation.bracket
88+
89+["(" ")"] @punctuation.bracket
90+
91+["[" "]"] @punctuation.bracket
92+
93+[
94+ ":"
95+ "."
96+] @punctuation.delimiter
97+
98+; Comments
99+[
100+ (comment)
101+ (documentation_comment)
102+] @comment