HarlemSquirrel / language-haml

Haml language grammar for GitHub's Atom IDE
MIT License
33 stars 24 forks source link

Multiline #20

Closed jclusso closed 8 years ago

jclusso commented 9 years ago

multiline code highlighting doesn't work in ruby haml.

=link_to settings_campaign_url(@campaign),
            class: active_page == "settings" ? "active" : "" do
cannikin commented 9 years ago

I've recently merged in a couple of pull requests, did that fix this for anyone?

jclusso commented 9 years ago

Nope. @cannikin, you gotta merge #22 which fixes a lot of things with multiline support. This however still is not resolved there as of last I checked.

screen shot 2014-11-24 at 3 36 26 pm

cannikin commented 9 years ago

Okay, watch to check out my master and make sure it works? GitHub was telling me it couldn't be automatically merged via pull request but when I did it locally it worked just fine, so I hope I didn't break something!

cannikin commented 9 years ago

If it looks good then I'll release an official version.

jclusso commented 9 years ago

Appears to fix everything but the ruby lines now. screen shot 2014-11-24 at 4 15 40 pm

jclusso commented 9 years ago

I tried to fix the ruby lines myself but I was struggling and it looked like @richrace was doing a good job on the other stuff. Maybe he can figure it out. My regex skills are weak and I have little experience writing these language files.

richrace commented 9 years ago

Right, for the multiline ruby code it's a bit complicated and not sure how to go about getting it to work.

Basically I have this regex: ((do|\{)( \|[^|]+\|)?)$|((\w|\}|"|\'|\))\s*(\|?)$) which when tested on these strings:

  = link_to_remote "Add to cart",
      :url => { :action => "add", :id => product.id },
      :update => { :success => "cart", :failure => "error" }
  .div
  = link_to_remote "Add to cart"
  .div
  = link_to_remote 'Add to cart'
  .div
  = link object
  .div
  = render(object,
    :template => "Test"
    )
  .div
  = link_to_remote "Add to cart", |
    :url => { :action => "add", :id => product.id }, |
    :update => { :success => "cart", :failure => "error" } |
  .div
  = link_to_remote "Add to cart", |
    :url => { :action => "add", :id => product.id }, |
    :update => "test" |
  .div

Should get the last terminator, and I believe it should go on this line: https://github.com/cannikin/language-haml/blob/master/grammars/ruby%20haml.cson#L207

However, I can't get it to work for all instances. For example, it works with the pipe terminators, but if you remove them then it breaks the rest of the formatting until there is a pipe.

I hope this helps you @jclusso and others :)

(This is the properly escaped regex for Atom: ((do|\\{)( \\|[^|]+\\|)?)$|((\\w|\\}|"|\'|\\))\\s*(\\|?)$))

jclusso commented 9 years ago

@richrace, this is for vim but tpope is a vim boss and his works :) https://github.com/tpope/vim-haml/blob/master/syntax/haml.vim Maybe you can get some ideas from that?

Either way, I'm gonna get my buddy who is much better at regex to help me look it. I'll update later tonight when I get a chance to play around with this.

richrace commented 9 years ago

Seems like the TextMate bundle, which this is based off, is having the same issue: https://github.com/textmate/ruby-haml.tmbundle/issues/9

jclusso commented 9 years ago

@richrace textmate and sublime both are broken on this functionality unfortunately :(

jclusso commented 9 years ago

I was unable to make any progress. Anyone else have any luck?

iRet commented 9 years ago

I found a problem with end of attributes '}' regex it works wrong when I'm using hashes inside attributes image

Just created PR to fix it image

jclusso commented 9 years ago

@iRet do you have any idea how to fix the ruby syntax?

iRet commented 9 years ago

@jclusso oh, haven't seen it yet, let me try

jclusso commented 9 years ago

@iRet if you fix that I'll be so happy :)! I gave up and I think @richrace did to because we both couldn't figure it out.

iRet commented 9 years ago

@jclusso just fixed ruby strings and updated PR Still see some issues with html tags but that's enough for today :) will dig it later image

jclusso commented 9 years ago

Awesome, @iRet! I'll try it out and see how it works

iRet commented 9 years ago

@jclusso sorry but it still buggy. Actually I can figure it out for sublime haml package, it's pretty same ported textmate bundle with a minor changes, but python regexp support negative lookahead, so we can say 'end of line but not prepended with comma'. Will try again this weekends.

jclusso commented 9 years ago

@iRet cool! I appreciate you trying to fix this

jclusso commented 9 years ago

@iRet did you ever get the ruby line working?

cannikin commented 9 years ago

Anything mergeable or we still looking at fixes?

iRet commented 9 years ago

@jclusso not fully, actually attributes and ruby lines looks ok now, but it caused new issues with haml/html tags test_html_haml_-__users_artyom_desktop_-_atom Still had no time for a deeper look into it. And switched to sublime, where I'm using similar fixes but it not causes this tags bug. I've just updated updated my PR if you interested in testing, another things seems fine as far as I tested.

iRet commented 9 years ago

It seems like problem not in rubyline end pattern, just tried to add quotes to it, no effect. And tags higlighted as text not as ruby code. It could be in html tag start pattern, but it is almost the same like in sublime package, so weird.

jclusso commented 9 years ago

Yea, idk if it's of any use but I linked above to a working syntax highlighter for vim written by tpope. I'm not well enough versed to pick the regex apart or i'd do it myself. @iRet

https://github.com/tpope/vim-haml/blob/master/syntax/haml.vim

olivierlacan commented 9 years ago

Anyone still working on this? This is still an issue in 0.21.0.

cannikin commented 9 years ago

Sorry, I was supposed to be transferring ownership of this to someone who had the time to devote to maintaining it. @ezekg offered to take it over a few months ago but I dropped the ball. Anyone else?

ezekg commented 8 years ago

@cannikin, if needed, I would like to help out with this still. I use this package every day.

cannikin commented 8 years ago

Great! Any idea what steps we go through to transfer ownership? Moving the repo should be easy? But I don't know about the APM package...

ezekg commented 8 years ago

I'm not entirely sure. I've never done that. I can look into it later today, though.

As far as I can tell, I think I have this issue resolved by rewriting the ruby haml.cson file (essentially just copying the current Sublime text implementation), and cleaning up a couple regexes (adding a little recursion for commas/blocks). I'll post it here soon and see if we can get a new version out to test.

When this issue is fixed, I want to start work on a PHP Haml grammar. I'll also need people to test the Coffee Haml, because I've never used that.

olivierlacan commented 8 years ago

I'd be down to help out once @ezekg takes over.

This is how you transfer ownership: https://atom.io/docs/latest/behind-atom-maintaining-your-packages#transferring-ownership

cannikin commented 8 years ago

Great! Transfer initiated! Apparently you just transfer ownership of the repo and the package will magically go over as well.

ezekg commented 8 years ago

I think I have everything working nicely. Still a couple issues with filters and trimmed whitespace, but nothing huge. Looking good. I'll continue to test this week before creating a new beta version. :+1:

image

Anything I should know about going package releases? Does it go by tagged releases?

jclusso commented 8 years ago

Nice that this finally looks to be getting fixed! Too bad we've started a heavy migration to Slim since Haml is just not nearly as fast. :(

olivierlacan commented 8 years ago

@ezekg More :cake: for you!

ezekg commented 8 years ago

Everybody test out the new version (0.22.0). Let me know if you find any new issues or edge cases I missed. I'm going to close this issue until told otherwise. :ok_hand: