Open dummdidumm opened 2 years ago
Hi, @dummdidumm! Thank you for all your work on the extension! I'm listing down all the issues I ran into below:
I wasn't able to add https://github.com/sveltejs/language-tools as a source for grammar directly because linguist picked up the JSON files here and ignored the YAML file. Linguist also said the JSON files were invalid grammar. Linguist also does not support pointing to a specific file, which meant I cannot use the language-tools repo as the source of grammar. Additionally, the answer to a question about the file extensions allowed meant that I had to rename the file extension from .yaml
to .YAML-tmLanugage
.
Next, linguist spit out a bunch of errors when it tried to add grammar from the .YAML-tmLanugage
file:
1 errors found in new grammar 'repository `vendor/grammars/svelte-syntax-highlighting-grammar` (from https://github.com/umanghome/svelte-syntax-highlighting-grammar.git)':
- Grammar conversion failed. File `svelte.YAML-tmLanguage` failed to parse: 58 error(s) decoding:
Compilation failed. Aborting
I was able to [convert all the integer object keys to strings](https://github.com/umanghome/svelte-syntax-highlighting-grammar/commit/b835751fea8a32f60eb5894c5ab71669628828ac) and these errors went away.
3. After that, it gave me errors about invalid regexes:
7 errors found in new grammar 'repository vendor/grammars/svelte-syntax-highlighting-grammar
(from https://github.com/umanghome/svelte-syntax-highlighting-grammar.git)':
source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=(if|key|then|catch|html).*?)
...": lookbehind assertion is not fixed length (at offset 31))source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=const.*?)\G
": lookbehind assertion is not fixed length (at offset 12))source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=each.*?)\G
": lookbehind assertion is not fixed length (at offset 11))source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=await.*?)\G
": lookbehind assertion is not fixed length (at offset 12))source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=debug.*?)\G
": lookbehind assertion is not fixed length (at offset 12))source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=(use|transition|in|out|anima
...": lookbehind assertion is not fixed length (at offset 36))source.svelte
(in svelte.YAML-tmLanguage
) contains a malformed regex (regex "(?<=(let|class|style):).*$
": lookbehind assertion is not fixed length (at offset 22))Compilation failed. Aborting
I did some searching on the Internet and was able to [update the regexes](https://github.com/umanghome/svelte-syntax-highlighting-grammar/commit/e4ce4681fd8e193897088f4273f55ad27091a66e) based on [a stack overflow answer](https://stackoverflow.com/a/40078049/4176188). The errors went away.
4. Finally, linguist warned about `css.postcss` not being in scope.
1 warnings found when compiling new grammar 'repository vendor/grammars/svelte-syntax-highlighting-grammar
(from https://github.com/umanghome/svelte-syntax-highlighting-grammar.git)':
OK! added grammar source 'vendor/grammars/svelte-syntax-highlighting-grammar'
new scope: source.svelte
source.svelte
(in svelte.YAML-tmLanguage
) attempts to include source.css.postcss
but the scope cannot be foundThese warnings are not fatal, but may mean the syntax highlighting on GitHub.com may not be as expected.
I did [a similar fix back in 2018](https://github.com/umanghome/svelte-atom/commit/adb5935d88775812a641645aed0651d708c4c71d) while adding support to linguist for Svelte. This is because unlike [scss](https://github.com/github/linguist/blob/737d12e24ad5f739934d29216229b8a22336e9ef/lib/linguist/languages.yml#L5907) and [friends](https://github.com/github/linguist/blob/737d12e24ad5f739934d29216229b8a22336e9ef/lib/linguist/languages.yml#L3514), [`postcss` is not in the `css` scope in linguist](https://github.com/github/linguist/blob/737d12e24ad5f739934d29216229b8a22336e9ef/lib/linguist/languages.yml#L5059). [This commit](https://github.com/umanghome/svelte-syntax-highlighting-grammar/commit/141678580a15fd68163a1452929abe0aa5649494) fixed the scope of postcss in the grammar.
Hi, I'm one of the maintainer of the Svelte for VS Code extension. Stoked to see that you're pushing to get Svelte syntax highlighting in proper shape on GitHub again!
Looking through the commits I see that you made some tweaks to the existing grammar from the language-tools repo. Could you elaborate a bit on these changes and if it would be worthwhile to backport some or all of them to our VS Code grammar? Particularly interested in the "fix regexes commit".
Thanks!