davidrios / jade-tmbundle

A comprehensive textmate / sublime text bundle for the Jade template language.
https://github.com/davidrios/jade-tmbundle
MIT License
102 stars 31 forks source link

False keywords mess up highlighting #61

Closed dalgard closed 8 years ago

dalgard commented 9 years ago

The screenshots below should explain the problem.

(The syntax around +include is Meteor-specific, but highlighting works fine there with other words.)

1-include_class

2-type_attr

3-class_attr

4-type_attr-last

5-other_keywords

davidrios commented 9 years ago

The problem with this and #56 is that they are conflicting with the official Jade implementation, which is really the focus of this highlighter. The solution would be to add another variant supporting meteor Jade, like the already existing Jade (Python), but since I don't use meteor I really have no reason to maintain it. If anyone feels up to the task, just send me a pull request.

dalgard commented 9 years ago

Thanks for the quick response.

I realize that the reason for the blue keyword with the following lack of Jade highlighting is that the JavaScript highlighter takes over. The fifth image shows it very clearly. However – even with vanilla Jade syntax alone – I think that control should be given back to the Jade highlighter after the first space following the keyword.

Isn't this correct? I mean, in regard to regular Jade syntax?

fregante commented 9 years ago

The latest updated did mess up the normal Jade syntax too, not just custom one.

Example:

mixin a
  a&attributes(attributes)
    block

+a()(class='demo-only')
  span.hello text

Result on http://jade-lang.com/

syntax from jade-lang.com

Result from jade-tmbundle:

syntax from jade-tmbundle

The thing is that it worked well until the last time I restarted ST3, now my files are unreadable :(

I guess setting the syntax to Jade (Python) fixes this for now.

syntax from jade-tmbundle / python

Sometimes that class comes from a variable so I can't just use it as .demo-only

davidrios commented 8 years ago

You are using the Babel package, right? The problem is that when I pass the highlighting to another language, I only get the control back when it stops, and the Babel JavaScript highlighter have rules for some keywords, like class and type, that are greedier than Sublime's default.

It's generally not a problem, as code like:

input(type=function placeholder='asdfsdf')

is invalid Jade anyway, but it can cause issues if some features implemented by Babel conflicts with your valid Jade code.

@dalgard I included a special case for mixin call with params in the form name=value which should solve your use case.

@bfred-it Your example suffered from the same incompatibility with Babel, but I was able to improve the matching for mixins, so now it's more accurate and working as expected.

fregante commented 8 years ago

Yep, that fixed it! Thank you :)