Skip to content
Browse files

Add :Rschema navigation command

  • Loading branch information...
1 parent defddd2 commit cccd2ad0613385d6e6ccf0041892be8348348ca8 Travis Jeffery committed with Nov 22, 2011
Showing with 23 additions and 0 deletions.
  1. +18 −0 autoload/rails.vim
  2. +5 −0 doc/rails.txt
View
18 autoload/rails.vim
@@ -2132,6 +2132,7 @@ function! s:BufFinderCommands()
call s:addfilecmds("controller")
call s:addfilecmds("mailer")
call s:addfilecmds("migration")
+ call s:addfilecmds("schema")
call s:addfilecmds("observer")
call s:addfilecmds("helper")
call s:addfilecmds("layout")
@@ -2287,6 +2288,14 @@ function! s:migrationList(A,L,P)
endif
endfunction
+function! s:schemaList(A,L,P)
+ let tables = s:readfile(rails#app().path('db/schema.rb'))
+ let table_re = '^\s\+create_table\s["'':]\zs[^"'',]*\ze'
+ call map(tables,'matchstr(v:val, table_re)')
+ call filter(tables,'strlen(v:val)')
+ return s:autocamelize(tables, a:A)
+endfunction
+
function! s:unittestList(A,L,P)
let found = []
if rails#app().has('test')
@@ -2516,6 +2525,15 @@ function! s:migrationEdit(cmd,...)
endif
endfunction
+function! s:schemaEdit(cmd,...)
+ let cmd = s:findcmdfor(a:cmd)
+ let schema = 'db/'.s:environment().'_structure.sql'
+ if rails#app().has_file('db/schema.rb') || !rails#app().has_file(schema)
+ let schema = 'db/schema.rb'
+ endif
+ call s:findedit(cmd,schema.(a:0 ? '#'.a:1 : ''))
+endfunction
+
function! s:fixturesEdit(cmd,...)
if a:0
let c = rails#underscore(a:1)
View
5 doc/rails.txt
@@ -271,6 +271,7 @@ itself!).
:Rmodel |rails-:Rmodel|
:Robserver |rails-:Robserver|
:Rplugin |rails-:Rplugin|
+:Rschema |rails-:Rschema|
:Rspec |rails-:Rspec|
:Rstylesheet |rails-:Rstylesheet|
:Rtask |rails-:Rtask|
@@ -378,6 +379,10 @@ itself!).
command is only defined if there is a spec folder in
the root of the application.
+ *rails-:Rschema*
+:Rschema [{table}] Edit the schema and optionally jump to the specified
+ table.
+
*rails-:Rstylesheet*
:Rstylesheet [{name}] Edit the stylesheet for the specified name or current
controller. Also supports Sass and SCSS.

0 comments on commit cccd2ad

Please sign in to comment.
Something went wrong with that request. Please try again.