Skip to content

Commit e461e51

Browse files
feat(grammars): add bicep (#325)
1 parent b92e403 commit e461e51

File tree

5 files changed

+169
-0
lines changed

5 files changed

+169
-0
lines changed

demo/db/db.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,24 @@
28552855
"id": "vH7mmfKH",
28562856
"createdAt": 1673326490808,
28572857
"updatedAt": 1673326641538
2858+
},
2859+
{
2860+
"isDeleted": false,
2861+
"isFavorites": false,
2862+
"folderId": "J7rNZi7X",
2863+
"tagsIds": [],
2864+
"description": null,
2865+
"name": "Bicep",
2866+
"content": [
2867+
{
2868+
"label": "Fragment 1",
2869+
"language": "bicep",
2870+
"value": "param rgLocation string = resourceGroup().location\nparam storages array = [\n {\n name: 'contoso'\n skuName: 'Standard_LRS'\n }\n {\n name: 'fabrikam'\n skuName: 'Premium_LRS'\n }\n]\n\nresource createStorages 'Microsoft.Storage/storageAccounts@2021-06-01' = [for storage in storages: {\n name: '${storage.name}obj${uniqueString(resourceGroup().id)}'\n location: rgLocation\n sku: {\n name: storage.skuName\n }\n kind: 'StorageV2'\n}]"
2871+
}
2872+
],
2873+
"id": "W9p-A0M9",
2874+
"createdAt": 1673328306847,
2875+
"updatedAt": 1673328471208
28582876
}
28592877
],
28602878
"tags": []

src/renderer/components/editor/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This is a list of language that supports in massCode.
1717
- AutoHotkey / AutoIt
1818
- Bash
1919
- BatchFile
20+
- Bicep
2021
- C and C++
2122
- C#
2223
- Cirru
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"scopeName": "source.bicep",
3+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
4+
"patterns": [{ "include": "#expression" }, { "include": "#comments" }],
5+
"repository": {
6+
"line-comment": {
7+
"name": "comment.line.double-slash.bicep",
8+
"match": "//.*(?=$)"
9+
},
10+
"keyword": {
11+
"name": "keyword.control.declaration.bicep",
12+
"match": "\\b(metadata|targetScope|resource|module|param|var|output|for|in|if|existing|import|as|type|with)\\b"
13+
},
14+
"object-literal": {
15+
"begin": "{",
16+
"end": "}",
17+
"patterns": [
18+
{ "include": "#object-property-key" },
19+
{ "include": "#expression" },
20+
{ "include": "#comments" }
21+
],
22+
"name": "meta.object-literal.bicep"
23+
},
24+
"string-literal-subst": {
25+
"begin": "(?<!\\\\)(\\${)",
26+
"endCaptures": {
27+
"1": { "name": "punctuation.definition.template-expression.end.bicep" }
28+
},
29+
"end": "(})",
30+
"patterns": [{ "include": "#expression" }, { "include": "#comments" }],
31+
"name": "meta.string-literal-subst.bicep",
32+
"beginCaptures": {
33+
"1": {
34+
"name": "punctuation.definition.template-expression.begin.bicep"
35+
}
36+
}
37+
},
38+
"array-literal": {
39+
"begin": "\\[(?!(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\bfor\\b)",
40+
"end": "]",
41+
"patterns": [{ "include": "#expression" }, { "include": "#comments" }],
42+
"name": "meta.array-literal.bicep"
43+
},
44+
"object-property-key": {
45+
"name": "variable.other.property.bicep",
46+
"match": "\\b[_$[:alpha:]][_$[:alnum:]]*\\b(?=(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*:)"
47+
},
48+
"string-verbatim": {
49+
"begin": "'''",
50+
"end": "'''",
51+
"patterns": [],
52+
"name": "string.quoted.multi.bicep"
53+
},
54+
"lambda-start": {
55+
"begin": "(\\((?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\b[_$[:alpha:]][_$[:alnum:]]*\\b(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*(,(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\b[_$[:alpha:]][_$[:alnum:]]*\\b(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*)*\\)|\\((?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\)|(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\b[_$[:alpha:]][_$[:alnum:]]*\\b(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*)(?=(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*=>)",
56+
"end": "(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*=>",
57+
"name": "meta.lambda-start.bicep",
58+
"beginCaptures": {
59+
"1": {
60+
"name": "meta.undefined.bicep",
61+
"patterns": [{ "include": "#identifier" }, { "include": "#comments" }]
62+
}
63+
}
64+
},
65+
"function-call": {
66+
"begin": "(\\b[_$[:alpha:]][_$[:alnum:]]*\\b)(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\(",
67+
"end": "\\)",
68+
"patterns": [{ "include": "#expression" }, { "include": "#comments" }],
69+
"name": "meta.function-call.bicep",
70+
"beginCaptures": { "1": { "name": "entity.name.function.bicep" } }
71+
},
72+
"escape-character": {
73+
"name": "constant.character.escape.bicep",
74+
"match": "\\\\(u{[0-9A-Fa-f]+}|n|r|t|\\\\|'|\\${)"
75+
},
76+
"identifier": {
77+
"name": "variable.other.readwrite.bicep",
78+
"match": "\\b[_$[:alpha:]][_$[:alnum:]]*\\b(?!(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*\\()"
79+
},
80+
"string-literal": {
81+
"begin": "'(?!'')",
82+
"end": "'",
83+
"patterns": [
84+
{ "include": "#escape-character" },
85+
{ "include": "#string-literal-subst" }
86+
],
87+
"name": "string.quoted.single.bicep"
88+
},
89+
"directive-variable": {
90+
"name": "keyword.control.declaration.bicep",
91+
"match": "\\b[_a-zA-Z-0-9]+\\b"
92+
},
93+
"directive": {
94+
"begin": "#\\b[_a-zA-Z-0-9]+\\b",
95+
"end": "$",
96+
"patterns": [
97+
{ "include": "#directive-variable" },
98+
{ "include": "#comments" }
99+
],
100+
"name": "meta.directive.bicep"
101+
},
102+
"decorator": {
103+
"begin": "@(?:[ \\t\\r\\n]|\\/\\*(?:\\*(?!\\/)|[^*])*\\*\\/)*(?=\\b[_$[:alpha:]][_$[:alnum:]]*\\b)",
104+
"end": "",
105+
"patterns": [{ "include": "#expression" }, { "include": "#comments" }],
106+
"name": "meta.decorator.bicep"
107+
},
108+
"block-comment": {
109+
"name": "comment.block.bicep",
110+
"begin": "/\\*",
111+
"end": "\\*/"
112+
},
113+
"comments": {
114+
"patterns": [
115+
{ "include": "#line-comment" },
116+
{ "include": "#block-comment" }
117+
]
118+
},
119+
"numeric-literal": { "name": "constant.numeric.bicep", "match": "[0-9]+" },
120+
"expression": {
121+
"patterns": [
122+
{ "include": "#string-literal" },
123+
{ "include": "#string-verbatim" },
124+
{ "include": "#numeric-literal" },
125+
{ "include": "#named-literal" },
126+
{ "include": "#object-literal" },
127+
{ "include": "#array-literal" },
128+
{ "include": "#keyword" },
129+
{ "include": "#identifier" },
130+
{ "include": "#function-call" },
131+
{ "include": "#decorator" },
132+
{ "include": "#lambda-start" },
133+
{ "include": "#directive" }
134+
]
135+
},
136+
"named-literal": {
137+
"name": "constant.language.bicep",
138+
"match": "\\b(true|false|null)\\b"
139+
}
140+
},
141+
"name": "Bicep",
142+
"fileTypes": [".bicep"]
143+
}

src/renderer/components/editor/languages.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ export const languages: LanguageOption[] = [
9292
grammar: () => import('./grammars/batchfile.tmLanguage.json'),
9393
scopeName: 'source.batchfile'
9494
},
95+
{
96+
name: 'Bicep',
97+
value: 'bicep',
98+
grammar: () => import('./grammars/bicep.tmLanguage.json'),
99+
scopeName: 'source.bicep'
100+
},
95101
{
96102
name: 'C and C++',
97103
value: 'c_cpp',

src/shared/types/renderer/editor/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type Language =
1414
| 'assembly_x86'
1515
| 'autohotkey'
1616
| 'batchfile'
17+
| 'bicep'
1718
| 'c_cpp'
1819
| 'c9search'
1920
| 'cirru'

0 commit comments

Comments
 (0)