tpope / vim-rails

rails.vim: Ruby on Rails power tools
http://www.vim.org/scripts/script.php?script_id=1567
4.1k stars 383 forks source link

Projections: Alternate with context of point #554

Closed nicosierra closed 4 years ago

nicosierra commented 4 years ago

Hi there!

TLDR: I was wondering whether we could consider the context of the point to filter it out and use it to set more granular rules.


Multiple times, I have encountered projects which have all sort of styles when it comes to split files into smaller chunks.

One example (of a rails project) could be:

A FooController with create, update, destroy methods, its tests spread through spec/controllers/foo/{ctx}_spec.rb, being {ctx} the name of the method above (e.g. spec/controllers/foo/create_spec.rb).

As per the documentation, if we were to set the alternate value for controllers to that of spec/controllers/{}/ folders, where {} is the filtered name of the controller, we would only be able to jump to one file, i.e. the first readable file.

A nice solution would be to set templates from the context, perhaps allowing us to define textObjects of the sort NearestMethod to set up that context.

Perhaps all this is an edge case in the rails community, although I see it as a useful feature for vim-projectionist in general.

tpope commented 4 years ago

The nearest method can be expanded with {define}. This isn't used for a bare :A; rather it is reserved for :.A and :R.