astro-vscode 0.18.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # astro-vscode
2
2
 
3
+ ## 0.19.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 59e8ad6: Update README, disable frontmatter indenting by default
8
+ - fec2817: Improved syntax highlighting, auto-indentation and auto-closing
9
+ - Updated dependencies [729dff5]
10
+ - Updated dependencies [05a48c2]
11
+ - Updated dependencies [fe2d26b]
12
+ - @astrojs/language-server@0.19.1
13
+
14
+ ## 0.19.0
15
+
16
+ ### Minor Changes
17
+
18
+ - a97b9a4: Add support for Inlay Hints. Minimum VS Code version supported starting from this update is 1.67.0 (April 2022)
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [a97b9a4]
23
+ - @astrojs/language-server@0.19.0
24
+
25
+ ## 0.18.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 666739a: Revert update to latest LSP and inlay hints support
30
+ - Updated dependencies [666739a]
31
+ - @astrojs/language-server@0.18.1
32
+
3
33
  ## 0.18.0
4
34
 
5
35
  ### Minor Changes
package/README.md CHANGED
@@ -2,26 +2,55 @@
2
2
 
3
3
  > 🧑‍🚀 Not sure what Astro is? See our website at [astro.build](https://astro.build)!
4
4
 
5
- Provides language support for `.astro` files. This extension is powered by the [Astro language server](https://github.com/withastro/language-tools/tree/main/packages/language-server)
5
+ Provides language support for `.astro` files. This extension is powered by the [Astro language server](https://github.com/withastro/language-tools/tree/main/packages/language-server).
6
6
 
7
7
  ## Features
8
8
 
9
- * [Go to Definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
10
- * Code hover hints
11
- * Code completion
12
- * Function signatures
13
- * Syntax highlighting
14
- * Code folding
15
- * Emmet
9
+ - Syntax & [semantic](https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide) highlighting
10
+ - [Diagnostic messages](https://code.visualstudio.com/docs/editor/editingevolved#_errors-warnings)
11
+ - [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense) completions ([w/ auto-imports](https://code.visualstudio.com/Docs/languages/typescript#_auto-imports))
12
+ - [Emmet completions](https://code.visualstudio.com/docs/editor/emmet) in HTML & CSS
13
+ - Props completions for JSX/TSX, Vue (Composition API only) and Svelte components
14
+ - [Code actions](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) (quick fixes, sort imports etc)
15
+ - [Formatting](https://code.visualstudio.com/docs/editor/codebasics#_formatting)
16
+ - [Symbols](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol) ([outline view](https://code.visualstudio.com/docs/getstarted/userinterface#_outline-view), [breadcrumb navigation](https://code.visualstudio.com/docs/editor/editingevolved#_breadcrumbs) etc)
17
+ - [Hover information](https://code.visualstudio.com/Docs/languages/typescript#_hover-information)
18
+ - [Go to Definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
19
+ - [Inlay hints](https://code.visualstudio.com/docs/editor/editingevolved#_inlay-hints)
20
+ - [Code folding](https://code.visualstudio.com/docs/editor/codebasics#_folding)
21
+
22
+ A TypeScript plugin adding support for importing Astro components inside JavaScript and TypeScript files is also included.
16
23
 
17
24
  ## Configuration
18
25
 
19
- You can disable most features in the extension by going to your workspace settings page. Under __Extension__ find Astro configuration and uncheck the feature you do not want. For example to disable error messages unselect __TypeScript > Diagnostics: Enable__.
26
+ You can disable most features in the extension by going to your workspace settings page. Under **Extension** find Astro configuration and uncheck the feature(s) you do not want. For example to disable error messages unselect **TypeScript > Diagnostics: Enable** (or in JSON, set `astro.typescript.diagnostics.enabled` to `false`).
27
+
28
+ Formatting and TypeScript settings can be configured using VS Code's HTML Format settings (`html.format.xxx`) and TypeScript settings (`typescript.xxx`) respectively.
20
29
 
21
30
  ## Troubleshooting
22
31
 
32
+ ### Unable to update to latest version
33
+
34
+ Starting from 0.19.0, the minimum VS Code version supported by this extension is 1.67.0 (April 2022). If using an older version of VS Code, 0.18.1 will be installed instead.
35
+
36
+ Before submitting an issue, please make sure you're using the latest version of both VS Code and the extension!
37
+
23
38
  ### Cannot find name "Astro" or Property 'env' does not exist on type 'ImportMeta' or Cannot find name "Fragment"
24
39
 
25
- Starting from 0.23.5 version of Astro and the 0.9 version of this extension, typechecking is now done using types that are provided by Astro itself. Therefore, to benefit from those included types, you need to use any version of Astro that is higher or equal to 0.23.5
40
+ Starting from 0.23.5 version of Astro and the 0.9 version of this extension, typechecking is now done using types that are provided by Astro itself. Therefore, to benefit from those included types, you need to use any version of Astro that is higher or equal to 0.23.5.
26
41
 
27
42
  If you can't upgrade to a newer version of Astro for the moment, you can downgrade the extension to the latest pre 0.9.0 version by right clicking the Astro extension in the sidebar and pressing "Install another version"
43
+
44
+ ### Inlay Hints don't work
45
+
46
+ Currently, only inlay hints provided by TypeScript are supported. TypeScript inlay hints are disabled by default and needs to be enabled using the settings under the `typescript.inlayHints` namespace, for example, to enable inlay hints for parameter names, you would do the following:
47
+
48
+ ```json
49
+ {
50
+ "typescript.inlayHints.parameterNames.enabled": "all"
51
+ }
52
+ ```
53
+
54
+ Alternatively, in the GUI this would be in **TypeScript > Inlay Hints > Parameter Names**. Make sure to update the TypeScript settings and not the JavaScript ones, as Astro is TypeScript-only
55
+
56
+ See [this page](https://code.visualstudio.com/Docs/languages/typescript#_inlay-hints) for more information on the different settings available for inlay hints
@@ -3,11 +3,9 @@
3
3
  "blockComment": ["<!--", "-->"]
4
4
  },
5
5
  "brackets": [
6
- ["---", "---"],
7
6
  ["<!--", "-->"],
8
7
  ["<", ">"],
9
- ["{", "}"],
10
- ["(", ")"]
8
+ ["{", "}"]
11
9
  ],
12
10
  "autoClosingPairs": [
13
11
  { "open": "{", "close": "}" },
@@ -16,13 +14,15 @@
16
14
  { "open": "'", "close": "'" },
17
15
  { "open": "\"", "close": "\"" },
18
16
  { "open": "`", "close": "`" },
19
- { "open": "<!--", "close": "-->", "notIn": ["comment", "string"] },
17
+ { "open": "{/*", "close": " */}", "notIn": ["comment", "string"] },
18
+ { "open": "<!--", "close": " -->", "notIn": ["comment", "string"] },
20
19
  { "open": "/**", "close": " */", "notIn": ["string"] }
21
20
  ],
22
21
  "autoCloseBefore": ";:.,=}])>` \n\t",
23
22
  "surroundingPairs": [
24
23
  { "open": "'", "close": "'" },
25
24
  { "open": "\"", "close": "\"" },
25
+ { "open": "`", "close": "`" },
26
26
  { "open": "{", "close": "}" },
27
27
  { "open": "[", "close": "]" },
28
28
  { "open": "(", "close": ")" },
@@ -33,5 +33,36 @@
33
33
  "start": "^\\s*<!--\\s*#region\\b.*-->",
34
34
  "end": "^\\s*<!--\\s*#endregion\\b.*-->"
35
35
  }
36
+ },
37
+ "wordPattern": {
38
+ "pattern": "([^\\-\\s]+-[^\\-\\s]+)|(-?\\d*\\.\\d\\w*)|([^\\`\\~\\-\\!\\@\\$\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:'\"\\,\\.\\<\\>\\/\\s]+)"
39
+ },
40
+ "onEnterRules": [
41
+ {
42
+ "beforeText": {
43
+ "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w\\-.\\d]*)([^/>]*(?!/)>)[^<]*$",
44
+ "flags": "i"
45
+ },
46
+ "afterText": {
47
+ "pattern": "^<\\/([_:\\w][_:\\w-.\\d]*)\\s*>$",
48
+ "flags": "i"
49
+ },
50
+ "action": {
51
+ "indent": "indentOutdent"
52
+ }
53
+ },
54
+ {
55
+ "beforeText": {
56
+ "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w\\-.\\d]*)([^/>]*(?!/)>)[^<]*$",
57
+ "flags": "i"
58
+ },
59
+ "action": {
60
+ "indent": "indent"
61
+ }
62
+ }
63
+ ],
64
+ "indentationRules": {
65
+ "increaseIndentPattern": "<(?!\\?|(?:area|base|br|col|frame|hr|html|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\\b|[^>]*\\/>)([-_\\.A-Za-z0-9]+)(?=\\s|>)\\b[^>]*>(?!.*<\\/\\1>)|<!--(?!.*-->)|\\{[^}\"']*$",
66
+ "decreaseIndentPattern": "^\\s*(<\\/(?!html)[-_\\.A-Za-z0-9]+\\b[^>]*>|-->|\\})"
36
67
  }
37
68
  }
package/package.json CHANGED
@@ -2,13 +2,28 @@
2
2
  "name": "astro-vscode",
3
3
  "displayName": "Astro",
4
4
  "description": "Language support for Astro",
5
+ "categories": [
6
+ "Programming Languages",
7
+ "Formatters",
8
+ "Linters"
9
+ ],
10
+ "qna": false,
11
+ "keywords": [
12
+ "astro",
13
+ "node",
14
+ "typescript",
15
+ "javascript",
16
+ "vue",
17
+ "svelte",
18
+ "Static site generator"
19
+ ],
5
20
  "icon": "assets/icon.png",
6
21
  "type": "commonjs",
7
22
  "galleryBanner": {
8
23
  "color": "#FFBE2D",
9
24
  "theme": "dark"
10
25
  },
11
- "version": "0.18.0",
26
+ "version": "0.19.1",
12
27
  "author": "withastro",
13
28
  "license": "MIT",
14
29
  "publisher": "astro-build",
@@ -16,26 +31,28 @@
16
31
  "vscode:prepublish": "yarn build",
17
32
  "build": "astro-scripts build \"src/**/*.ts\" && tsc -p tsconfig.json",
18
33
  "dev": "astro-scripts dev \"src/**/*.ts\"",
19
- "test": "node ./test/runTest.js"
34
+ "test": "yarn run test:vscode && yarn run test:grammar",
35
+ "test:vscode": "node ./test/runTest.js",
36
+ "test:grammar": "node ./test/grammar/test.mjs",
37
+ "update-grammar-snapshots": "node ./test/grammar/test.mjs --updateSnapshot"
20
38
  },
21
39
  "engines": {
22
- "vscode": "^1.56.0"
40
+ "vscode": "^1.67.0"
23
41
  },
24
42
  "activationEvents": [
25
43
  "onLanguage:astro",
26
44
  "workspaceContains:astro.config.*"
27
45
  ],
28
46
  "dependencies": {
29
- "@astrojs/language-server": "0.18.0",
47
+ "@astrojs/language-server": "0.19.1",
30
48
  "@astrojs/ts-plugin": "0.2.1",
31
- "vscode-languageclient": "^8.0.0"
49
+ "vscode-languageclient": "^8.0.1"
32
50
  },
33
51
  "devDependencies": {
34
- "@types/glob": "^7.2.0",
35
- "@types/vscode": "^1.56.0",
52
+ "@types/vscode": "^1.67.0",
36
53
  "@vscode/test-electron": "^2.1.3",
37
- "astro-scripts": "file:../../scripts",
38
- "glob": "^7.2.0"
54
+ "vscode-tmgrammar-test": "^0.1.1",
55
+ "astro-scripts": "file:../../scripts"
39
56
  },
40
57
  "main": "./dist/index.js",
41
58
  "browser": "./dist/index.js",
@@ -211,13 +228,15 @@
211
228
  },
212
229
  "astro.format.indentFrontmatter": {
213
230
  "type": "boolean",
214
- "default": true,
215
- "title": "Formatting: Indent the frontmatter by one level of indentation"
231
+ "default": false,
232
+ "title": "Formatting: Indent frontmatter",
233
+ "description": "Indent the formatter by one level of indentation"
216
234
  },
217
235
  "astro.format.newLineAfterFrontmatter": {
218
236
  "type": "boolean",
219
237
  "default": true,
220
- "title": "Formatting: Add a line return between the frontmatter and the template"
238
+ "title": "Formatting: Add line return after the frontmatter",
239
+ "description": "Add a line return between the frontmatter and the template"
221
240
  }
222
241
  }
223
242
  },
@@ -252,6 +271,7 @@
252
271
  "source.stylus": "stylus",
253
272
  "source.js": "javascript",
254
273
  "source.ts": "typescript",
274
+ "source.json": "json",
255
275
  "source.tsx": "typescriptreact"
256
276
  }
257
277
  },
@@ -68,25 +68,64 @@
68
68
  ]
69
69
  },
70
70
  "astro:component": {
71
- "name": "meta.tag.component.astro",
72
- "begin": "(</?)([$A-Z_][^/?!\\s<>]*|[^/?!\\s<>.]+\\.[^/?!\\s<>]+)\\b",
73
- "beginCaptures": {
74
- "1": {
75
- "name": "punctuation.definition.tag.begin.astro"
76
- },
77
- "2": {
78
- "name": "entity.name.tag.astro support.class.component.astro"
79
- }
80
- },
81
- "end": "(/?>)",
82
- "endCaptures": {
83
- "1": {
84
- "name": "punctuation.definition.tag.end.astro"
85
- }
86
- },
87
71
  "patterns": [
88
72
  {
89
- "include": "#astro:attribute"
73
+ "name": "meta.tag.component.astro astro.component.raw",
74
+ "begin": "(<)([$A-Z_][^/?!\\s<>]*|[^/?!\\s<>.]+\\.[^/?!\\s<>]+)(.+is:raw.*?)(>)",
75
+ "end": "(</)([$A-Z_][^/?!\\s<>]*|[^/?!\\s<>.]+\\.[^/?!\\s<>]+)(?=\\s|/?>)(>)",
76
+ "beginCaptures": {
77
+ "1": {
78
+ "name": "punctuation.definition.tag.begin.astro"
79
+ },
80
+ "2": {
81
+ "name": "entity.name.tag.astro support.class.component.astro"
82
+ },
83
+ "3": {
84
+ "patterns": [
85
+ {
86
+ "include": "#astro:attribute"
87
+ }
88
+ ]
89
+ },
90
+ "4": {
91
+ "name": "punctuation.definition.tag.end.astro"
92
+ }
93
+ },
94
+ "endCaptures": {
95
+ "1": {
96
+ "name": "punctuation.definition.tag.begin.astro"
97
+ },
98
+ "2": {
99
+ "name": "entity.name.tag.astro support.class.component.astro"
100
+ },
101
+ "3": {
102
+ "name": "punctuation.definition.tag.end.astro"
103
+ }
104
+ },
105
+ "contentName": "source.unknown"
106
+ },
107
+ {
108
+ "name": "meta.tag.component.astro",
109
+ "begin": "(</?)([$A-Z_][^/?!\\s<>]*|[^/?!\\s<>.]+\\.[^/?!\\s<>]+)\\b",
110
+ "beginCaptures": {
111
+ "1": {
112
+ "name": "punctuation.definition.tag.begin.astro"
113
+ },
114
+ "2": {
115
+ "name": "entity.name.tag.astro support.class.component.astro"
116
+ }
117
+ },
118
+ "end": "(/?>)",
119
+ "endCaptures": {
120
+ "1": {
121
+ "name": "punctuation.definition.tag.end.astro"
122
+ }
123
+ },
124
+ "patterns": [
125
+ {
126
+ "include": "#astro:attribute"
127
+ }
128
+ ]
90
129
  }
91
130
  ]
92
131
  },
@@ -131,6 +170,47 @@
131
170
  }
132
171
  },
133
172
  "patterns": [
173
+ {
174
+ "comment": "Treat script tag with application/ld+json as JSON. This needs to be higher than is:raw since it's a very possible situation to have is:raw on a JSON script tag",
175
+ "begin": "\\G(?=\\s*[^>]*?type\\s*=\\s*(['\"]|)(?i:application/ld\\+json)\\1)",
176
+ "end": "(?=</|/>)",
177
+ "patterns": [
178
+ {
179
+ "begin": "(?<=>)(?!</)",
180
+ "end": "(?=</)",
181
+ "contentName": "source.json",
182
+ "patterns": [{ "include": "source.json" }]
183
+ },
184
+ { "include": "#html:tag-attributes" }
185
+ ]
186
+ },
187
+ {
188
+ "comment": "Treat script tag with JS-compatible types as JS",
189
+ "begin": "\\G(?=\\s*[^>]*?type\\s*=\\s*(['\"]|)(?i:module|(?:text/javascript|text/partytown|application/node|application/javascript))\\1)",
190
+ "end": "(?=</|/>)",
191
+ "patterns": [
192
+ {
193
+ "begin": "(?<=>)(?!</)",
194
+ "end": "(?=</)",
195
+ "contentName": "source.js",
196
+ "patterns": [{ "include": "source.js" }]
197
+ },
198
+ { "include": "#html:tag-attributes" }
199
+ ]
200
+ },
201
+ {
202
+ "comment": "Treat anything with an unknown type as unknown",
203
+ "begin": "\\G(?=\\s*[^>]*?type\\s*=\\s*(['\"]|)\\1)",
204
+ "end": "(?=</|/>)",
205
+ "patterns": [
206
+ {
207
+ "begin": "(?<=>)(?!</)",
208
+ "end": "(?=</)",
209
+ "name": "source.unknown"
210
+ },
211
+ { "include": "#html:tag-attributes" }
212
+ ]
213
+ },
134
214
  {
135
215
  "begin": "\\G(?=\\s*[^>]*?lang\\s*=\\s*(['\"]|)(?i:jsx?|javascript)\\1)",
136
216
  "end": "(?=</|/>)",
@@ -367,6 +447,41 @@
367
447
  },
368
448
  "html:element": {
369
449
  "patterns": [
450
+ {
451
+ "name": "astro.element.raw",
452
+ "begin": "(<)([^/?!\\s<>]+)(.+is:raw.*?)(>)",
453
+ "end": "(</)([^/?!\\s<>]+)(?=\\s|/?>)(>)",
454
+ "beginCaptures": {
455
+ "1": {
456
+ "name": "punctuation.definition.tag.begin.html"
457
+ },
458
+ "2": {
459
+ "name": "entity.name.tag.html"
460
+ },
461
+ "3": {
462
+ "patterns": [
463
+ {
464
+ "include": "#astro:attribute"
465
+ }
466
+ ]
467
+ },
468
+ "4": {
469
+ "name": "punctuation.definition.tag.end.html"
470
+ }
471
+ },
472
+ "endCaptures": {
473
+ "1": {
474
+ "name": "punctuation.definition.tag.begin.html"
475
+ },
476
+ "2": {
477
+ "name": "entity.name.tag.html"
478
+ },
479
+ "3": {
480
+ "name": "punctuation.definition.tag.end.html"
481
+ }
482
+ },
483
+ "contentName": "source.unknown"
484
+ },
370
485
  {
371
486
  "name": "meta.tag.any.$2.start.html",
372
487
  "begin": "(<)([^/?!\\s<>]+)(?=\\s|/?>)",
@@ -445,16 +560,16 @@
445
560
  "begin": "\\{",
446
561
  "beginCaptures": {
447
562
  "0": {
448
- "name": "punctuation.definition.generic.begin.html"
563
+ "name": "punctuation.section.embedded.begin.tsx"
449
564
  }
450
565
  },
451
566
  "end": "\\}",
452
567
  "endCaptures": {
453
568
  "0": {
454
- "name": "punctuation.definition.generic.end.html"
569
+ "name": "punctuation.section.embedded.end.tsx"
455
570
  }
456
571
  },
457
- "name": "expression.embbeded.astro",
572
+ "name": "expression.embedded.astro",
458
573
  "contentName": "source.tsx",
459
574
  "patterns": [
460
575
  {
@@ -500,10 +615,11 @@
500
615
  ]
501
616
  },
502
617
  "frontmatter": {
618
+ "comment": "The frontmatter is treated as comments in order to get the \"faded\" look",
503
619
  "begin": "\\A(-{3})\\s*$",
504
620
  "beginCaptures": {
505
621
  "1": {
506
- "name": "comment.block.html"
622
+ "name": "comment"
507
623
  }
508
624
  },
509
625
  "contentName": "source.ts",
@@ -515,7 +631,7 @@
515
631
  "end": "(^|\\G)(-{3})|\\.{3}\\s*$",
516
632
  "endCaptures": {
517
633
  "2": {
518
- "name": "comment.block.html"
634
+ "name": "comment"
519
635
  }
520
636
  }
521
637
  },