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

Not using configured JS syntax inside <script> block #194

Open
dsl101 opened this issue Feb 3, 2020 · 5 comments
Open

Not using configured JS syntax inside <script> block #194

dsl101 opened this issue Feb 3, 2020 · 5 comments

Comments

@dsl101
Copy link

dsl101 commented Feb 3, 2020

The documentation suggests the <script> block will use whatever syntax is used for regular .js files, but I'm getting very different results in Vue SFC <script> vs plain .js files. My default syntax is JavaScript Next, and looks like this (correct):

image

but that code in a Vue SFC looks like this (many things miscoloured):

image

There are lots of other differences too, and I can get the effect in plain .js files by switching to the built-in Javascript syntax (which is the reason I moved to JS Next). So, is there a way to be explicit about which syntax to use, or is there just a bug not picking up the configured .js syntax setting?

@rchl
Copy link

rchl commented Feb 4, 2020

https://packagecontrol.io/packages/JavaScriptNext%20-%20ES6%20Syntax is not maintained for 2 years now. Official syntax by now has implemented probably all and more of what JavaScriptNext supports. It's not a good idea to keep using it. Even if you think that highlighting is better in it ("better" being subjective as official highlighting might make more sense consistency wise).

@skyronic
Copy link
Collaborator

skyronic commented Feb 5, 2020

Have you tried disabling the default javascript package?

Ctrl+Shift+P -> Disable Package -> JavaScript

@dsl101
Copy link
Author

dsl101 commented Feb 5, 2020

OK, several separate thoughts:

  • The official syntax doesn't highlight functions (definitions or calls) properly for me. I know this could be a color scheme issue, but I'm just going round in circles and JS Next has been working perfectly for a long time.
  • "It's old" isn't a reason for v-s-h not using it, is it?
  • Are the docs inaccurate (v-s-h doesn't use the configured highlighter), or is there a bug?
  • I've tried disabling the built-in JavaScript highlighter, but v-s-h still seems to use it. Not sure how, but the scopes reported by ScopeHunter are identical inside the Vue component to what the built-in JavaScript syntax reports when it is enabled.
  • I will also see if the color scheme (Monokai++) can be updated to work with how the built-in highlighter labels the scopes.

@dsl101
Copy link
Author

dsl101 commented Feb 5, 2020

In fact, I've removed JSNext and re-enabled the built-in JavaScript syntax, and I notice several differences between the scopes from a .vue file and a .js file. Small example in a plain .js file:

image

The components key scope is:

source.js
meta.export.js
meta.object-literal.js
meta.object-literal.key.js

but in a .vue file:

image

with:

text.html.vue
source.js.embedded.html
source.js
meta.export.js
meta.mapping.js
meta.mapping.key.js
string.unquoted.js

Doesn't seem like that is the same syntax highlighter being used for the JS part...

@ada-ada-ada-art
Copy link

I have a similar issue. Interestingly the syntax highlight is correct, if I set lang=ts. Which I am not interested in doing for this component though.

Capture d’écran 2020-05-20 à 20 35 30

Capture d’écran 2020-05-20 à 20 35 38

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

No branches or pull requests

4 participants