Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Vue Grammar #7086

Merged
merged 3 commits into from
Nov 25, 2024
Merged

Conversation

yuichkun
Copy link
Contributor

@yuichkun yuichkun commented Oct 12, 2024

This PR replaces the Vue.js grammar vendor from vuejs/vue-syntax-highlight to vuejs/language-tools.
The grammar file is located at https://github.com/vuejs/language-tools/blob/master/extensions/vscode/syntaxes/vue.tmLanguage.json

Description

Background:
There have been some issues stating that Vue's syntax breaks when certain newly introduced TypeScript syntax are present, such as optional chaining operator (?).

Related Issues:

Fix:

Since vuejs/vue-syntax-highlight has long been not updated (last commit is 4 years ago), and also there's even a collaborator of vuejs/language-tools suggesting linguist should switch Vue's grammar vendor to vuejs/language-tools (see this comment), here's the PR.

I'm not exactly sure if this really fixes all the problems, but I followed the CONTRIBUTING.md and just ran the following:

./script/add-grammar --replace vue-syntax-highlight https://github.com/vuejs/language-tools/blob/mast
er/extensions/vscode/syntaxes/vue.tmLanguage.json

In the script log, I found the following warnings:

5 warnings found when compiling new grammar 'repository `vendor/grammars/language-tools` (from https://github.com/vuejs/language-tools.git)':
- Unknown keys in grammar: `source.vue` (in `extensions/vscode/syntaxes/vue.tmLanguage.json`) contains invalid keys (`Repository[vue-directives-original].Patterns[0].1`, `Repository[vue-directives-original].Patterns[0].2`)
- Missing include in grammar: `source.vue` (in `extensions/vscode/syntaxes/vue.tmLanguage.json`) attempts to include `source.js.jsx` but the scope cannot be found
- Missing include in grammar: `source.vue` (in `extensions/vscode/syntaxes/vue.tmLanguage.json`) attempts to include `source.json.comments` but the scope cannot be found
- Missing include in grammar: `source.vue` (in `extensions/vscode/syntaxes/vue.tmLanguage.json`) attempts to include `source.json5` but the scope cannot be found
- Missing include in grammar: `source.vue` (in `extensions/vscode/syntaxes/vue.tmLanguage.json`) attempts to include `text.html.derivative` but the scope cannot be found

These warnings are not fatal, but may mean the syntax highlighting on GitHub.com may not be as expected.

Is this fine?

Checklist:

grammars.yml Show resolved Hide resolved
@yuichkun yuichkun marked this pull request as ready for review October 12, 2024 19:47
@yuichkun yuichkun requested a review from a team as a code owner October 12, 2024 19:47
@lildude
Copy link
Member

lildude commented Oct 14, 2024

Is this fine?

It's fine in as much as Linguist and the syntax highlighter don't care. It might not be fine for users as these messages indicate that those particular scopes can't be found so the rules from them won't be applied when highlighting a file.

@yuichkun
Copy link
Contributor Author

yuichkun commented Oct 15, 2024

@lildude

The CI was failing with the following error:

  1) Failure:
TestLanguage#test_all_languages_have_grammars [test/test_language.rb:361]:
The following languages' scopes are not listed in grammars.yml. Please add grammars for all new languages.
If no grammar exists for a language, mark the language with `tm_scope: none` in lib/linguist/languages.yml.
Vue text.html.vue

And I assumed that I have to set tm_scope to source.vue in lib/linguist/languages.yml, so that it corresponds to the scope name specified in the new repo here.
So I fixed it so in ecb907d

Am I in the right direction?

Thank you for taking your time to review

@lildude
Copy link
Member

lildude commented Oct 15, 2024

Am I in the right direction?

Yup. That's the right thing to do.

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Note: this PR will not be merged until close to when the next release is made. See here for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants