Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add :Rschema command #122

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

travisjeffery commented Oct 18, 2011

Hey Tim,

I've implemented a :Rschema that when calling with a given table name
as an argument, Vim will jump to the table's position in the db/schema.rb file.
When no argument is given :Rschema will use the current file's model's table
name, and jump to it's position in db/schema.rb. Similar to how :R behaves when
called inside a model file.

Thanks,

Travis

Travis Jeffery Add :Rschema command
When calling :Rschema with a given table name as an argument, Vim will
jump to the table's position in the db/schema.rb file. When no argument
is given :Rschema will use the current file's model's table name, and
jump to it's position in db/schema.rb. Similar to how :R behaves when
called inside a model file.
dce7d3a
Owner

tpope commented Nov 20, 2011

I guess what's been bothering me about this is it's weird to me to have one command for jumping in one file while all the other commands are for jumping to a set of files. That's not really a great reason to shoot it down though. I think I will allow it, but I want the tab completion to be absolutely perfect. This means scraping the table names out of db/schema.rb (and maybe the index names too). I don't mind implementing this myself, but you've seen how slow I work, so you're welcome to take a stab at it yourself. :)

Note that you can also achieve this with :Rmigration #table. An ugly interface, to be sure.

Travis Jeffery Improve :Rschema Completion
Improve :Rschema completion by extracting the list of tables from the
db/schema.rb file itself.
cd2cb83
Owner

tpope commented Nov 22, 2011

Okay, I've added docs, bikeshedded the hell out of it, committed in your name, and pushed it to a branch. I'm wondering if it's really necessary to jump to the table by default. You can already do that with :R, and there's no way to force :Rschema to jump to the top of the file instead.

Contributor

travisjeffery commented Nov 22, 2011

I like how it's jumps by default (as in, given with no args, right?), and I
feel it's similar to how :Rcontroller and :Rmodel, etc. go to the
controller and model for the current file by default.

Yeah, you can do it with :R but only from the model. It's nice to be able to
access the schema quickly from anywhere.

I guess I/we have to think about your last point some more. I'll just throw out
some thoughts, it's a low probability someone would want to go there, and if
they did it's going to be very fast to get there by :Rschema<CR>gg. One
option would be a bang, i.e. :Rschema!, another would be some kind of symbol
as an argument like '.', i.e. :Rschema . would take you to the top.

I think the bang option is best.

Owner

tpope commented Nov 22, 2011

I was looking for feedback when I started writing that comment, but by the time I finished I knew the answer. This isn't set in stone, but for now I'm merging in the top of the file variant. After a few weeks playing with it, maybe I'll change my mind.

@tpope tpope closed this Feb 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment