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 properly highlighting HTML attributes in (...) syntax #59

Closed
janko opened this issue Apr 4, 2014 · 8 comments
Closed

Not properly highlighting HTML attributes in (...) syntax #59

janko opened this issue Apr 4, 2014 · 8 comments

Comments

@janko
Copy link

janko commented Apr 4, 2014

Most standard ones are properly highlighted, but arbitrary ones aren't. Is it possible to just highlight all the attributes the same, regardless of their name (like it is in native HTML tags)?

screen shot 2014-04-04 at 15 08 13

@tpope
Copy link
Owner

tpope commented Apr 4, 2014

The native HTML highlighting uses 2 different colors. If you want to implement that for Haml, go for it. But that effort might be better expended on just fixing the HTML syntax highlighting to support HTML 5.

@janko
Copy link
Author

janko commented Apr 4, 2014

Hmm, I added otree/html5.vim to my vimfiles, which, judging by its source code, should take care of all of this, but for some reason it doesn't. I tried opening a normal HTML file and zSing over a data-* attribute returns htmlArg htmlTag; however, in a Haml file zSing over a data-* attribute returns only hamlAttributes (while other normal ones return also htmlArg).

Do you have any idea what could be wrong? I double-checked with :Scriptnames if html5.vim's syntax/html.vim was loaded.

@tpope
Copy link
Owner

tpope commented Apr 4, 2014

You need to :set iskeyword+=-. Try it in an after file and see how well it works. I'm worried it will have serious side effects for the Ruby

@tpope
Copy link
Owner

tpope commented Apr 5, 2014

See othree/html5.vim#5 for a way to contribute a more promising solution.

@janko
Copy link
Author

janko commented Apr 5, 2014

Wow, thank you for putting your time into this. Hmm, I still don't get why data-* attributes don't work if there is

syn match   htmlArg "\<\(data\(\-[a-z]\+\)\+\)\=\>" contained

It shouldn't be dependend on the iskeyword, right?

The solution that worked for me was adding an after/syntax/html.vim:

runtime! syntax/html/aria.vim
runtime! syntax/html/rdfa.vim

set iskeyword+=-

I don't think it messes with the Ruby highlighting, only if _ is removed as an iskeyword.

@janko
Copy link
Author

janko commented Apr 5, 2014

I think I will submit a pull request to merge html/aria.vim and html/rdfa.vim into html.vim. Also, I found the need to :set iskeyword+=- alarming at first, but now I don't really see any downsides.

@tpope
Copy link
Owner

tpope commented Apr 5, 2014

Because data by itself highlights as a keyword, and keywords have higher precedence than matches.

@janko
Copy link
Author

janko commented Apr 5, 2014

Aaaa, I get it. Thank you for all your help, I really have much deeper understanding of the problem now, and I can act by myself now.

@janko janko closed this as completed Apr 5, 2014
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

2 participants