vim-rails
vim-rails copied to clipboard
Projections: handling partial view names
I'm using projections for Curly in order to jump from a template to a presenter and back. I've currently got this JSON:
{
"app/presenters/*_presenter.rb": {
"affinity": "controller",
"command": "presenter",
"test": "spec/presenters/%s_presenter_spec.rb",
"related": "app/views/%s.html.curly",
"template": "class %SPresenter < Curly::Presenter\nend",
"keywords": "presents depends_on version"
},
"app/views/*.html.curly": {
"affinity": "controller",
"test": "spec/views/%s_spec.rb",
"related": "app/presenters/%s_presenter.rb"
}
}
It works fine for normal views, but breaks down for partials – app/views/foo/_bar.html.curly should go to app/presenters/foo/bar_presenter.rb and vice versa – the problem is that %s expands to foo/_bar. It would be great if there was support for these additional formats:
- The leading path up to but not including the last part, i.e.
foo/bar/bazwould becomefoo/bar. - The last part, i.e.
foo/bar/_bazwould become_baz. - The last part excluding any leading underscore, so
foo/bar/_bazwould becomebaz.
That would fix my problems I think.
@dasch have you taken a shot at fixing this yourself in vim-rails? If not, wanna pair on it?
@prognostikos sure!
I haven't gotten around to looking at fixing it myself.
I aim to port over the slightly different expansions from projectile.vim in the near future. This should enable solving half the problem with {dirname}/_{basename}. Speak up in tpope/vim-projectile#3 if you have ideas for the other half.
@dasch did you ever get a configuration that works with curly set up?
Nah, never got around to it.