eschulte / rinari

Rinari Is Not A Rails IDE (it is an Emacs minor mode for Rails)
http://rinari.rubyforge.org
GNU General Public License v3.0
412 stars 68 forks source link

Syntax highlighting #47

Closed asok closed 11 years ago

asok commented 11 years ago

vim-rails has got really nice syntax highlighting for words specific to rails like belongs_to, redirect_to and so on. Should rinari define additional keywords or it is more a case of individual setup?

purcell commented 11 years ago

Yeah, I guess it would be possible to rip the full list of keywords out of https://github.com/tpope/vim-rails/blob/master/autoload/rails.vim, then apply font-lock-add-keywords to them in any rinari ruby-mode buffer... Rinari doesn't really have the same concept of "current buffer type", so it wouldn't be easy to use subsets of keywords specific to models, tests etc.

asok commented 11 years ago

If you call font-lock-add-keywords with nil major-mode it will fontify only the current buffer. We might call it from the find-file-hook and apply just some keywords based on the current buffer's file path.

asok commented 11 years ago

I've added second commit that should capture word boundaries in ruby correctly.

purcell commented 11 years ago

Does that work for you with the regular ruby mode? It doesn't work for me.

I've been fiddling with it to tidy things up and get things working, but I haven't managed it yet; here are my changes so far: e3415d68badf5a. Among other changes, I've borrowed the matching logic from ruby-mode (note that regexp-opt is a clever little function); the generated regexes work beautifully in M-x regex-builder, but not when included in the font lock keywords...

asok commented 11 years ago

Actually I'm using this qoobaa/ruby-mode and both mine code and yours are working with it.

purcell commented 11 years ago

Yeah, this works for me in a clean Emacs instance, so it's clashing with something else.

I've merged your changes to master now - thanks! :-)

asok commented 11 years ago

You're welcome :) There's only one thing missing that are views. Here https://github.com/asok/rinari/commit/85a2ea23cde03758c47e7ff9ad98696280569ed8 I've added keywords for views. I'm not using mmm-mode but rather rhtml-mode and haml-mode. In the *.erb files it looks nice. But in *.haml it's not. = render is not highlighted. But just render yes.