-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat: support JavaScript syntax on template #150
base: master
Are you sure you want to change the base?
Conversation
This support: 1. Non-zero length dynamic values (:attr="variable"); 2. Zero length dynamic values (:attr=""); 3. Slots syntax (#name) now have JavaScript syntax also (#default="{ thisHere }"); There is also comments explaining commands and the mustache syntax is considered htmlSpecialChar, because it's easier to see them that way. Closes posva#143
Oh wait, this has a bug 😅 <img
:alt="'foo bar baz'"
> this is breaking the syntax 🤔 donno how to fix, I wouldn't merge this right now |
Fixed, we can merge again 😅 😂 |
So I've been using it for a while and haven't seem anymore errors |
Hi! First of all, thanks for all the effort! Looks very promising. I took some time to try it out with a barebones vim config (including othree/html5.vim and pangloss/vim-javascript) but it didn't seem to fully work for me. In this basic example, the class attribute binding doesn't get highlighted as JavaScript. Can you see what is going wrong here? |
hey, I'm investigating this and I discovered that if you insert in your let g:vue_pre_processors = [] The hightlighing begins to work, but now my lunch break is over, so I will continue investigating this asap 😄 thanks for the feedback ❤️ |
Other discovery is that: having \ {'name': 'pug', 'tag': 'template', 'attr_pattern': s:attr('lang', '\%(pug\|jade\)')},
\ {'name': 'slm', 'tag': 'template'},
\ {'name': 'handlebars', 'tag': 'template'},
\ {'name': 'haml', 'tag': 'template'}, " <<<<- this here
\ {'name': 'typescript', 'tag': 'script', 'attr_pattern': '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)'},
\ {'name': 'coffee', 'tag': 'script'},
\ {'name': 'stylus', 'tag': 'style'}, breaks the syntax 🤔 when I remove the haml line, it works, very strange... |
Interesting, I also remember having to change the order of that array in order to make some syntax highlighting work. I can confirm that it works when I set Maybe it's reasonable to use |
Yeah, I guess I do agree with you regarding the "detect_on_enter" on default. But the problem happens when the |
Ok, I'm thinking about it here, I have the smallest clue about using haml and a even smaller one about using haml with vue, but for what I could see in some examples here on github... I don't think the code I made even applies anyway, because the syntax is really different, in fact I think this same logic applies to the other |
Yeah that seems like a good solution to me. If we ever want to add support for this to other templating languages, we will probably need to make specific adjustments anyway. |
…g with this syntax E.g.: `xmlns:xlink="http://www.w3.org/1999/xlink"` This commit prevents this kinda error by enforcing the use of a whitespace character before the dynamic attribute
Other syntaxes where clashing and they just didn't work properly
docs: update docs on change of default behavior
So, I've mauled over this problem for a while now, and I just can't find a way to make this work without changing the default value of Do we agree on changing the default value for this option? And if so, can someone help me with the tests that are breaking? 😅 sorry for the trouble 🙁 |
I think the tests are failing because not all languages are loaded now. Maybe it's best to add support for setting the option to |
technically using function! s:should_register(language, start_pattern)
" Check whether a syntax file for {language} exists
if empty(globpath(&runtimepath, 'syntax/' . a:language . '.vim'))
return 0
endif
if exists('g:vue_pre_processors')
if type(g:vue_pre_processors) == v:t_list
return index(g:vue_pre_processors, s:language.name) != -1
elseif g:vue_pre_processors is# 'detect_on_enter'
return search(a:start_pattern, 'n') != 0
endif
endif
return 1
endfunction Should we add an explicity maybe just a comment on the script "hey, |
769ded6
to
c168b9c
Compare
also, I think it would be better from the user perspective if we mantain the ability to pre-load some resources, so how about we adopt an api like this: let g:vue_pre_processors = ['scss', 'detect_on_enter'] Thoughts? |
Eager load html, because it's not a pre-processor, and being loaded since the start (for the tags), it's kinda counter intuitive that you need to load the html pre-processor if the syntax is already mostly correct.
…ally Since we are now supporting other scripting languages as well.
prevent this section from being separated by the "s:languages" logic
Now it also highlights script stuff inside the template for other script languages like typescript and coffescript |
This support:
:attr="variable"
);:attr=""
);#default="{ thisHere }"
);v-text="'foo'"
);:[thisHere]="{ thisAlso: 1 }"
);There is also comments explaining commands and the mustache syntax is
considered
htmlSpecialChar
, because it's easier to see them that way.Closes #143