Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Starting basic Cell support #61

wants to merge 2 commits into from

2 participants


Hey Tim,

I'm kinda liking the idea of "Apotomo Widgets": , so I started to add some basic functionality to rails.vim. Frankly, this is my first real vimscript hacking, so I'm going in small chunks.

Anyway, I guess the real question is: does this belong in rails.vim? or should there be a new vim script such as apotomo.vim?

Then again, feel free to reject outright. =)



Hi Brad,

I am indeed pretty reluctant to add support for third party libraries, partially because there's so damn many and they change so fast, and partially because rails.vim is already a 5000 line monster without them. I only heard about Apotomo this week. I'm certainly not ready to commit to it long term, although everything is on a case-by-case basis.

For example, your change to s:readable_controller_name() is only two lines, has a relatively low maintenance cost, is hella useful (if indeed a cell name corresponds to a controller name; that's not my initial impression but I haven't looked at Apotomo that closely), and most importantly, is more or less impossible to pull off from outside of rails.vim. Put that in a separate patch and I'll accept it.

On the other hand, adding a navigation command takes 3 hunks to implement, interfaces with some old brittle navigation code I don't really want anything else to depend on, and is easily implemented from outside with a simple :Rnavcommand cell app/cells. The path changes are pretty easy to pull off externally as well. Syntax highlighting isn't quite that straightforward but is definitely doable. Every plugin or gem out the has some macro it wants highlighted; the only one I've caved in on is RSpec.

I also see you touched the old project.vim code. That's been deprecated for over a year; now seems like a good time to ax it for good.


Thanks for the guidance; I'm just another one of those recent vim converts flailing about to make my life slightly easier. Time to take a serious stab at fully ingesting vim-rails/doc/rails.txt.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2010
  1. @listrophy

    Add basic cell support

    listrophy authored listrophy committed
  2. @listrophy

    Add trigger to cell

    listrophy authored listrophy committed
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 5 deletions.
  1. +23 −5 autoload/rails.vim
28 autoload/rails.vim
@@ -342,6 +342,8 @@ function! s:readable_controller_name(...) dict abort
return s:sub(f,'.*<app/mailers/(.{-})\.rb$','\1')
elseif f =~ '\<app/apis/.*_api\.rb$'
return s:sub(f,'.*<app/apis/(.{-})_api\.rb$','\1')
+ elseif f =~ '\<app/cells/.*\.rb$'
+ return s:sub(f,'.*<app/cells/(.{-})\.rb$','\1')
elseif f =~ '\<test/functional/.*_test\.rb$'
return s:sub(f,'.*<test/functional/(.{-})%(_controller)=_test\.rb$','\1')
elseif f =~ '\<test/unit/helpers/.*_helper_test\.rb$'
@@ -698,6 +700,8 @@ function! s:readable_calculate_file_type() dict abort
let r = "view-partial-" . e
elseif f =~ '\<app/views\>.*\.' || f =~ '\<components/.*/.*\.'.s:viewspattern().'$'
let r = "view-" . e
+ elseif f =~ '\<app/cells/.*\.rb'
+ let r = "cell-" . e
elseif f =~ '\<test/unit/.*_test\.rb$'
let r = "test-unit"
elseif f =~ '\<test/functional/.*_test\.rb$'
@@ -2135,6 +2139,7 @@ function! s:BufFinderCommands()
call s:addfilecmds("metal")
call s:addfilecmds("model")
call s:addfilecmds("view")
+ call s:addfilecmds("cell")
call s:addfilecmds("controller")
call s:addfilecmds("mailer")
call s:addfilecmds("migration")
@@ -2227,6 +2232,10 @@ function! s:mailerList(A,L,P)
return s:autocamelize(rails#app().relglob("app/mailers/","**/*",".rb"),a:A)
+function! s:cellList(A,L,P)
+ return s:autocamelize(rails#app().relglob("app/cells/","**/*",".rb"),a:A)
function! s:viewList(A,L,P)
let c = s:controller(1)
let top = rails#app().relglob("app/views/",s:fuzzyglob(a:A))
@@ -2555,6 +2564,10 @@ function! s:observerEdit(cmd,...)
call s:EditSimpleRb(a:cmd,"observer",a:0? a:1 : s:model(1),"app/models/","_observer.rb")
+function! s:cellEdit(cmd,...)
+ call s:EditSimpleRb(a:cmd,"cell",a:1,"app/cells/",".rb")
function! s:viewEdit(cmd,...)
if a:0 && a:1 =~ '^[^!#:]'
let view = matchstr(a:1,'[^!#:]*')
@@ -3545,6 +3558,11 @@ function! s:BufSyntax()
syn keyword rubyRailsRenderMethod render
syn keyword rubyRailsMethod logger polymorphic_path polymorphic_url
+ if buffer.type_name('cell')
+ syn keyword rubyRailsMethod responds_to_event after_add after_initialize has_widgets param
+ syn keyword rubyRailsRenderMethod render
+ syn keyword rubyRailsMethod replace update render_children render_children_for trigger
+ endif
if buffer.type_name('helper','view')
exe "syn keyword rubyRailsHelperMethod ".s:gsub(s:helpermethods(),'<%(content_for|select)\s+','')
syn match rubyRailsHelperMethod '\<select\>\%(\s*{\|\s*do\>\|\s*(\=\s*&\)\@!'
@@ -3972,7 +3990,7 @@ endfunction
function! s:NewProjectTemplate(proj,rr)
let str = a:proj.'="'.a:rr."\" CD=. filter=\"*\" {\n"
let str .= " app=app {\n"
- for dir in ['apis','controllers','helpers','models','views']
+ for dir in ['apis','controllers','helpers','models','views','cells']
let str .= s:addprojectdir(a:rr,'app',dir)
let str .= " }\n"
@@ -3984,7 +4002,7 @@ function! s:NewProjectTemplate(proj,rr)
let str .= " public=public {\n images=images {\n }\n javascripts=javascripts {\n }\n stylesheets=stylesheets {\n }\n }\n"
if isdirectory(a:rr.'/spec')
let str .= " spec=spec {\n"
- for dir in ['controllers','fixtures','helpers','models','views']
+ for dir in ['controllers','fixtures','helpers','models','views','cells']
let str .= s:addprojectdir(a:rr,'spec',dir)
let str .= " }\n"
@@ -4165,7 +4183,7 @@ function! s:BufAbbreviations()
if g:rails_abbreviations
let buffer = rails#buffer()
" Limit to the right filetypes. But error on the liberal side
- if buffer.type_name('controller','view','helper','test-functional','test-integration')
+ if buffer.type_name('controller','view','cell','helper','test-functional','test-integration')
Rabbrev pa[ params
Rabbrev rq[ request
Rabbrev rs[ response
@@ -4610,7 +4628,7 @@ function! s:SetBasePath()
let old_path = s:pathsplit(s:sub(self.getvar('&path'),'^\.%(,|$)',''))
call filter(old_path,'!s:startswith(v:val,transformed_path)')
- let path = ['app', 'app/models', 'app/controllers', 'app/helpers', 'config', 'lib', 'app/views']
+ let path = ['app', 'app/models', 'app/controllers', 'app/helpers', 'config', 'lib', 'app/views', 'app/cells']
if self.controller_name() != ''
let path += ['app/views/'.self.controller_name(), 'public']
@@ -4618,7 +4636,7 @@ function! s:SetBasePath()
let path += ['test', 'test/unit', 'test/functional', 'test/integration']
- let path += ['spec', 'spec/models', 'spec/controllers', 'spec/helpers', 'spec/views', 'spec/lib', 'spec/requests', 'spec/integration']
+ let path += ['spec', 'spec/models', 'spec/controllers', 'spec/helpers', 'spec/views', 'spec/cells', 'spec/lib', 'spec/requests', 'spec/integration']
let path += ['app/*', 'vendor', 'vendor/plugins/*/lib', 'vendor/plugins/*/test', 'vendor/rails/*/lib', 'vendor/rails/*/test']
call map(path,'')
Something went wrong with that request. Please try again.