I recently cloned rails.vim (vim-rails) hoping to modify it to work with Padrino projects.
Currently I'm trying to get the Rcontroller
command to look not only in app/controllers (perfect for rails) but also in any folder in the project that has a sub-folder called 'controllers'. So when I type Rcontroller in command-mode and hit tab, I should be able to tab through admin/controllers/base.rb
, admin/controllers/accounts.rb
, app/controllers/events.rb
etc. This will let users of the plugin to jump to controllers in a 'subapp' of a Padrino application. e.g. PADRINO_ROOT/admin
The current controllerList
function seems to handle this autocompletion and here's what I have so far (only slightly modified from the original source)
function! s:controllerList(A,L,P)
let con = padrino#app().relglob("*/controllers/","**/*",".rb")
call map(con,'s:sub(v:val,"_controller$","")')
return s:autocamelize(con,a:A)
endfunction
I added the wildcard before the controllers directory but this gives results like
Rcontroller ers/base
Rcontroller ers/sessions
Rcontroller s/events
for the last one it looks like there is somethings weird going on with string lengths or overlap...
Ideally I'd like to get it to the point where typing Rcontroller admin<TAB>
should result in autocompletion to Rcontroller admin/controllers/accounts.rb
. Likewise, Rcontroller app<TAB>
should result in Rcontroller app/controllers/events.rb
The code for the viewList
function has something similar to this and its code is as follows:
function! s:viewList(A,L,P)
let c = s:controller(1)
let top = padrino#app().relglob("app/views/",s:fuzzyglob(a:A))
call filter(top,'v:val !~# "\\~$"')
if c != '' && a:A !~ '/'
let local = padrino#app().relglob("app/views/".c."/","*.*[^~]")
return s:completion_filter(local+top,a:A)
endif
return s:completion_filter(top,a:A)
endfunction
Anyone have any suggestions? Thanks in advance.