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

Highlight <script> and <style> tags better. #88

Closed
wants to merge 2 commits into from

Conversation

cyberdummy
Copy link

Fixes #76.

Use the javascript syntax for <script> & <script lang="javascript">
Use the css syntax for <style> & <sytle lang="css">
@kylethebaker
Copy link

This is an essential PR for me, without it I end up with the same syntax highlighting as if I did set filetype=html which isn't too friendly on the JS side of things. With the PR I get the proper js highlighting inside of the script tags.

Copy link
Collaborator

@adriaanzon adriaanzon left a comment

Choose a reason for hiding this comment

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

The <script> and <style> tags were actually intentionally left out, to let the html.vim script do the highlighting of javascript and css. Can you attach a screenshot of the differences?

Also, are you using https://github.com/pangloss/vim-javascript or the default one shipped with vim?

unlet! b:current_syntax
execute 'syntax region vue_' . a:language
\ 'keepend'
\ 'start=/<' . a:tag . '>/'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This lacks the \_[^>]* from s:register_language(), it's for maintaining the highlighting when the tag contains other, unrelated attributes.

However I think the s:register_language() function can be reused to highlight <script> and <style> as well, since it's not that different. I can have a further look at this too when I find some time

@kylethebaker
Copy link

@adriaanzon Here is a screenshot of the different modes I experience: https://i.imgur.com/S1r6sxF.png

I am using https://github.com/jelera/vim-javascript-syntax but I get the same results using the default vim syntax highlighting.

If I use vim-javascript I get correct syntax highlighting without the pull request, and this syntax also effects the javascript syntax highlighting when filetype=html.

So I think my issue is that my html syntax highlighting is no good for javascript. If I had to take a guess I would say that the reason this PR fixes it is that it explicitly registers the javascript syntax versus relying on html.

@adriaanzon adriaanzon self-assigned this Feb 22, 2018
@mbriggs
Copy link

mbriggs commented May 23, 2018

what is the current status on this? is there a plan to merge at some point?

@despreston
Copy link

is this dead?

@adriaanzon
Copy link
Collaborator

The current highlighting is fine for me, so I don't really want to hurt the loading time by sourcing syntax/javascript.vim and syntax/css.vim an extra time. However, I would be fine with an option variable that enables this behavior.

@cyberdummy cyberdummy closed this Apr 15, 2022
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.

Javascript syntax highlighting not working in script tag
5 participants