-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use Vetur for Vue grammar #4014
Conversation
Could you elaborate? Did you write the grammar from scratch? |
@pchaigno OK, got it working... Notice the Two questions:
|
I don't think it's possible to load several grammars unfortunately. @lildude may know more.
Linguist knows which grammar to load from the |
I forked from vue-syntax-highlight but rewrote a lot of sections.
I have multiple grammars that have scope
|
Just for the record, this PR is officially endorsed by the Vue team so it's ok to replace |
I am not a lawyer, but as far as I understand the MIT license, you'll need to keep the original copyright notice in addition to your own.
I see. @lildude Do you know which grammar is selected in that case on github.com?
AFAIK, it's only Lightshow that can't load multiple grammars at once; it shouldn't be an issue on github.com. |
I've looked into this and it's because the compiler can't find your grammar files for some reason:
Your grammar has
... so these should have been found by the compiler. @vmg, do you know why these files weren't picked up? The fact they're not being found also explains why you didn't see the two errors. As for the other questions:
Yup, Lightshow currently only allows selecting one grammar at a time, and you'll understand why in mo.
GitHub doesn't have support for custom or dynamically generated grammars, nor multiple scopes for a single grammar. GitHub will use the scope for the language Linguist identifies as per the If you want to use multiple scopes, you'll need to uniquely identify them and add them to Linguist as separate uniquely identifiable languages, like CSound has done https://github.com/github/linguist/blob/f7835f71191af350730becc12d5f062698c8e7af/lib/linguist/languages.yml#L875-L902. I'm not sure this is something you can do with Vue though. On a side note, I need to get an update of Linguist out for GItHub.com today, so I'll be doing so using the current Vue grammar. |
@lildude Giving it a try again. The only hurdle for me now is in VS Code side, slm is marked as Since it seems impossible to give scope aliases, I'm planning to split the grammar from Vetur to vuejs/vue-textmate, where I have
I'll then update the PR to:
Does this sound reasonable to you? |
@lildude One sec, so CSound has only 304 results in GitHub search and you considered adding it. Can we add slm language which has 934 files? @vmg Thanks for the fix.
Sure, I'll do that for vuejs/vue-textmate. |
Your explanation seems reasonable to me on the face of it, though I may be missing something that may come up later, but that's why we have multiple reviewers on PRs 😁.
From a quick look, probably not, for three reasons:
Reasoning for the last point: |
I've updated PR. Here are the test errors from
1 and 2 I don't quite understand. 3 I'm wondering why it's failing as vue seems to be a valid codemirror mode: https://github.com/codemirror/CodeMirror/tree/master/mode/vue |
@pchaigno I also added third party licenses notice to Vetur repo: https://github.com/vuejs/vetur/blob/master/ThirdPartyNotices.txt Is it sufficient or do I need to have a copy of vue-syntax-highlight's license in this repo too? |
ace_mode: html | ||
codemirror_mode: vue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1) Failure:
TestLanguage#test_codemirror_modes_present [/home/travis/build/github/linguist/test/test_language.rb:424]:
#<Linguist::Language name=Vue> missing CodeMirror MIME mode
... is happening because you're missing a codemirror_mime_type: <blah>
entry right about here.
lib/linguist/languages.yml
Outdated
type: markup | ||
tm_scope: text.html.vue-html | ||
ace_mode: html | ||
codemirror_mode: vue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need a codemirror_mime_type: <blah>
here too.
lib/linguist/languages.yml
Outdated
language_id: 391 | ||
Vue Template: | ||
type: markup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is essentially HTML, it's probably a good idea to group it with HTML(add group: HTML
to this section) like the many other HTML templating languages do.
Thanks for the feedback! Think I addressed them. However I think |
lib/linguist/languages.yml
Outdated
ace_mode: html | ||
codemirror_mode: vue | ||
codemirror_mime_type: text/html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Travis build is failing because this reference cannot be found in CodeMirror. I think you want text/x-vue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Was busy with other things and didn't notice Travis was failing.
I don't know; I'm not a lawyer. In any case, it's for you to decide and it is not blocking for the PR to be merged. |
I can clear the license problems as the author of vue-syntax-highlight. |
The new Travis-CI error is unrelated to this pull request. |
@lildude I think I fixed all your requested changes. Anything still blocking? |
Only a review from one of the other collaborators that is needed before I will put my stamp in it 😄 |
I'm not sure I followed here (which is the reason why I restrained from approving directly); do we have a working grammar in the end? Is there a fully-working Lightshow example? |
Nudge. Looks like we're still looking for a response to:
You'll also need to address the conflicts before this PR can be merged. |
@pchaigno Currently Lightshow is offline, but even when it's online, it cannot handle showing 2 grammars. I have links in this comment: #4014 (comment) What the vue grammar does: splitting each region into embedded languages, like:
What the vue-html grammar does: it handles vue-specific interpolations and differ from html grammar. That's why it has to be another grammar. Lightshow can load either grammar directly: https://github.com/vuejs/vetur/blob/master/syntaxes/vue.json and https://github.com/vuejs/vetur/blob/master/syntaxes/vue-html.json. The expected glitch is when you load vue grammar, since vue-html grammar cannot be loaded due to Lightshow limitation, everything inside the Let me know any more questions you have. I'll solve the merge conflicts soon. |
Ooops. I meant to post an issue for this this morning. Just done it now - #4168 |
Lightshow is back (forgot to come back and nudge this one when it came back). Please update your fork. |
This pull request has been automatically marked as stale because it has not had recent activity, and will be closed if no further activity occurs. If this pull request was overlooked, forgotten, or should remain open for any other reason, please reply here to call attention to it and remove the stale status. Thank you for your contributions. |
This pull request has been automatically closed because it has not had activity in a long time. Please feel free to reopen it or create a new issue. |
I'll open another one later. Hope lightshow works this time... |
Using https://github.com/vuejs/vetur instead of https://github.com/vuejs/vue-syntax-highlight for Vue syntax highlighting. Since:
Description
The
./script/add-grammar --replace
didn't work, so I looked at previous PR and did it manually.There are two tests not passing but don't seem to be related to my change.
Changes
The lightshow app doesn't seem to work for me.
Others
I did not find these two errors from #3924 when running test:
/cc @lildude @yyx990803