Note that there are some explanatory texts on larger screens.

plurals
  1. POHacking rails.vim to work with Padrino
    text
    copied!<p>I recently cloned rails.vim (vim-rails) hoping to modify it to work with Padrino projects. </p> <p>Currently I'm trying to get the <code>Rcontroller</code> 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 <code>admin/controllers/base.rb</code>, <code>admin/controllers/accounts.rb</code>, <code>app/controllers/events.rb</code> etc. This will let users of the plugin to jump to controllers in a 'subapp' of a Padrino application. e.g. <code>PADRINO_ROOT/admin</code></p> <p>The current <code>controllerList</code> function seems to handle this autocompletion and here's what I have so far (only slightly modified from the original source)</p> <pre><code>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 </code></pre> <p>I added the wildcard before the controllers directory but this gives results like</p> <ul> <li><code>Rcontroller ers/base</code></li> <li><code>Rcontroller ers/sessions</code></li> <li><code>Rcontroller s/events</code></li> </ul> <p>for the last one it looks like there is somethings weird going on with string lengths or overlap...</p> <p>Ideally I'd like to get it to the point where typing <code>Rcontroller admin&lt;TAB&gt;</code> should result in autocompletion to <code>Rcontroller admin/controllers/accounts.rb</code>. Likewise, <code>Rcontroller app&lt;TAB&gt;</code> should result in <code>Rcontroller app/controllers/events.rb</code></p> <p>The code for the <code>viewList</code> function has something similar to this and its code is as follows:</p> <pre><code> 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 != '' &amp;&amp; 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 </code></pre> <p>Anyone have any suggestions? Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload