Permalink
Browse files

update rails

  • Loading branch information...
1 parent 9a2dbdd commit 3333cc2bfe0b19d2855b262acd1b258fac9d5717 @bleything committed Sep 23, 2011
Showing with 269 additions and 427 deletions.
  1. +0 −10 bundle/rails/README
  2. +145 −0 bundle/rails/README.markdown
  3. +0 −56 bundle/rails/Rakefile
  4. +89 −216 bundle/rails/autoload/rails.vim
  5. +33 −142 bundle/rails/doc/rails.txt
  6. +2 −3 bundle/rails/plugin/rails.vim
View
10 bundle/rails/README
@@ -1,10 +0,0 @@
-rails.vim
-
-To install, simply copy autoload/rails.vim, plugin/rails.vim, and
-doc/rails.txt to the appropriate directories in ~/.vim. Alternatively,
-`rake install` may be used.
-
-See doc/rails.txt for documentation.
-
-Copyright Tim Pope. This plugin is licensed under the same terms as Vim
-itself. No warranties, expressed or implied.
View
145 bundle/rails/README.markdown
@@ -0,0 +1,145 @@
+rails.vim
+=========
+
+Remember when everybody and their mother was using TextMate for Ruby on
+Rails development? Well if it wasn't for rails.vim, we'd still be in
+that era. So shut up and pay some respect. And check out these
+features:
+
+* Easy navigation of the Rails directory structure. `gf` considers
+ context and knows about partials, fixtures, and much more. There are
+ two commands, `:A` (alternate) and `:R` (related) for easy jumping
+ between files, including favorites like model to migration, template
+ to helper, and controller to functional test. For more advanced
+ usage, `:Rmodel`, `:Rview`, `:Rcontroller`, and several other commands
+ are provided. `:help rails-navigation`
+
+* Enhanced syntax highlighting. From `has_and_belongs_to_many` to
+ `distance_of_time_in_words`, it's here. For easy completion of these
+ long method names, `'completefunc'` is set to enable syntax based
+ completion on CTRL-X CTRL-U.
+
+* Interface to rake. Use `:Rake` to run the current test, spec, or
+ feature. Use `:.Rake` to do a focused run of just the method,
+ example, or scenario on the current line. `:Rake` can also run
+ arbitrary migrations, load individual fixtures, and more.
+ `:help rails-rake`
+
+* Interface to `script/*`. Generally, use `:Rscript about` to call
+ `script/about` or `script/rails about`. Most commands have wrappers
+ with additional features: `:Rgenerate controller Blog` generates a
+ blog controller and edits `app/controllers/blog_controller.rb`.
+ `:help rails-scripts`
+
+* Partial extraction and migration inversion. `:Rextract {file}`
+ replaces the desired range (ideally selected in visual line mode) with
+ `render :partial => '{file}'`, which is automatically created with
+ your content. The `@{file}` instance variable is replaced with the
+ `{file}` local variable. `:Rinvert` takes a `self.up` migration and
+ writes a `self.down`. `:help rails-refactoring`
+
+* Integration with other plugins. `:Rtree` spawns
+ [NERDTree.vim](https://github.com/scrooloose/nerdtree). If
+ [dbext.vim](http://www.vim.org/scripts/script.php?script_id=356) is
+ installed, it will be transparently configured to reflect
+ `database.yml`. Users of
+ [abolish.vim](https://github.com/tpope/vim-abolish) get pluralize and
+ tableize coercions, and users of
+ [bundler.vim](https://github.com/tpope/vim-bundler) get `bundle exec
+ rake`. `:help rails-integration`
+
+Installation
+------------
+
+If you don't have a preferred installation method, I recommend
+installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
+then simply copy and paste:
+
+ cd ~/.vim/bundle
+ git clone git://github.com/tpope/vim-rails.git
+
+Once help tags have been generated, you can view the manual with
+`:help rails`.
+
+FAQ
+---
+
+> I installed the plugin and started Vim. Why does only the :Rails
+> command exist?
+
+This plugin cares about the current file, not the current working
+directory. Edit a file from a Rails application.
+
+> I opened a new tab. Why does only the :Rails command exist?
+
+This plugin cares about the current file, not the current working
+directory. Edit a file from a Rails application. You can use the `:RT`
+family of commands to open a new tab and edit a file at the same time.
+
+> Can I use rails.vim to edit other Ruby projects?
+
+I wrote [rake.vim](https://github.com/tpope/vim-rake) for exactly that
+purpose. It activates for any project with a `Rakefile` that's not a
+Rails application.
+
+> Is Rails 3 supported yet?
+
+Of course.
+
+> Is Rails 2 still supported?
+
+Baby, you can go all the way back to Rails 1 if you like (give or take
+some syntax highlighting).
+
+> Rake is slow. How about making `:Rake` run
+> `testrb`/`rspec`/`cucumber` directly instead of `rake`?
+
+Well then it wouldn't make sense to call it `:Rake`, now, would it?
+Maybe one day I'll add a separate `:Run` command or something. In the
+meantime, here's how you can set up `:make` to run the current test:
+
+ autocmd FileType cucumber compiler cucumber | setl makeprg=cucumber\ \"%:p\"
+ autocmd FileType ruby
+ \ if expand('%') =~# '_test\.rb$' |
+ \ compiler rubyunit | setl makeprg=testrb\ \"%:p\" |
+ \ elseif expand('%') =~# '_spec\.rb$' |
+ \ compiler rspec | setl makeprg=rspec\ \"%:p\" |
+ \ else |
+ \ compiler ruby | setl makeprg=ruby\ -wc\ \"%:p\" |
+ \ endif
+ autocmd User Bundler
+ \ if &makeprg !~ 'bundle' | setl makeprg^=bundle\ exec\ | endif
+
+Contributing
+------------
+
+If your [commit message sucks](http://stopwritingramblingcommitmessages.com/),
+I'm not going to accept your pull request. I've explained very politely
+dozens of times that
+[my general guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
+are absolute rules on my own repositories, so I may lack the energy to
+explain it to you yet another time. And please, if I ask you to change
+something, `git commit --amend`.
+
+Beyond that, don't be shy about asking before patching. What takes you
+hours might take me minutes simply because I have both domain knowledge
+and a perverse knowledge of VimScript so vast that many would consider
+it a symptom of mental illness. On the flip side, some ideas I'll
+reject no matter how good the implementation is. "Send a patch" is an
+edge case answer in my book.
+
+Self-Promotion
+--------------
+
+Like rails.vim? Follow the repository on
+[GitHub](https://github.com/tpope/vim-rails) and vote for it on
+[vim.org](http://www.vim.org/scripts/script.php?script_id=1567). And if
+you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
+[Twitter](http://twitter.com/tpope) and
+[GitHub](https://github.com/tpope).
+
+License
+-------
+
+Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
+See `:help license`.
View
56 bundle/rails/Rakefile
@@ -1,56 +0,0 @@
-require 'rake'
-require 'rake/contrib/sshpublisher'
-
-files = ['autoload/rails.vim', 'plugin/rails.vim', 'doc/rails.txt']
-
-desc "Make zip file"
-file 'rails.zip' => files do |t|
- File.unlink t.name if File.exists?(t.name)
- system('zip','-q',t.name,*t.prerequisites)
-end
-
-desc "Make vimball"
-file 'rails.vba' => files do |t|
- File.unlink t.name if File.exists?(t.name)
- File.open(t.name,"w") do |out|
- out.puts '" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.'
- out.puts 'UseVimball'
- out.puts 'finish'
- t.prerequisites.each do |name|
- File.open(name) do |file|
- file.each_line {}
- out.puts name
- out.puts file.lineno
- file.rewind
- file.each_line {|l|out.puts l}
- end
- end
- end
-end
-
-task :publish => [:zip,:vimball] do
- Rake::SshFilePublisher.new("tpope.net","/var/www/railsvim",".","rails.zip","rails.vba").upload
-end
-
-desc "Install"
-task :install do
- vimfiles = if ENV['VIMFILES']
- ENV['VIMFILES']
- elsif RUBY_PLATFORM =~ /(win|w)32$/
- File.expand_path("~/vimfiles")
- else
- File.expand_path("~/.vim")
- end
-
- puts "Installing rails.vim"
- files.each do |file|
- target_file = File.join(vimfiles, file)
- FileUtils.mkdir_p(File.dirname(target_file))
- FileUtils.cp(file, target_file)
- puts " Copied #{file} to #{target_file}"
- end
-end
-
-task 'zip' => 'rails.zip'
-task 'vimball' => 'rails.vba'
-task :default => [:zip, :vimball]
View
305 bundle/rails/autoload/rails.vim
@@ -1,12 +1,12 @@
" autoload/rails.vim
-" Author: Tim Pope <vimNOSPAM@tpope.org>
+" Author: Tim Pope <http://tpo.pe/>
" Install this file as autoload/rails.vim.
if exists('g:autoloaded_rails') || &cp
finish
endif
-let g:autoloaded_rails = '4.3'
+let g:autoloaded_rails = '4.4'
let s:cpo_save = &cpo
set cpo&vim
@@ -316,10 +316,10 @@ endfunction
call s:add_methods('readable',['end_of','last_opening_line','last_method_line','last_method','last_format','define_pattern'])
-let s:view_types = 'rhtml,erb,rxml,builder,rjs,mab,liquid,haml,dryml,mn'
+let s:view_types = split('rhtml,erb,rxml,builder,rjs,mab,liquid,haml,dryml,mn,slim',',')
function! s:viewspattern()
- return '\%('.s:gsub(s:view_types,',','\\|').'\)'
+ return '\%('.join(s:view_types,'\|').'\)'
endfunction
function! s:controller(...)
@@ -608,7 +608,7 @@ endfunction
function! s:buffer_name() dict abort
let app = self.app()
- let f = s:gsub(fnamemodify(bufname(self.number()),':p'),'\\ @!','/')
+ let f = s:gsub(resolve(fnamemodify(bufname(self.number()),':p')),'\\ @!','/')
let f = s:sub(f,'/$','')
let sep = matchstr(f,'^[^\\/]\{3,\}\zs[\\/]')
if sep != ""
@@ -1010,29 +1010,17 @@ function! rails#new_app_command(bang,...)
endif
return
endif
- let dir = ""
- if a:1 !~ '^-' && a:1 !=# 'new'
- let dir = a:1
- elseif a:{a:0} =~ '[\/]'
- let dir = a:{a:0}
- else
- let dir = a:1
- endif
- let str = ""
- let c = 1
- while c <= a:0
- let str .= " " . s:rquote(expand(a:{c}))
- let c += 1
- endwhile
- let dir = expand(dir)
- let append = ""
+ let args = map(copy(a:000),'expand(v:val)')
if a:bang
- let append .= " --force"
- endif
- exe "!rails".append.str
- if filereadable(dir."/".g:rails_default_file)
- edit `=dir.'/'.g:rails_default_file`
+ let args = ['--force'] + args
endif
+ exe '!rails '.join(map(copy(args),'s:rquote(v:val)'),' ')
+ for dir in args
+ if dir !~# '^-' && filereadable(dir.'/'.g:rails_default_file)
+ edit `=dir.'/'.g:rails_default_file`
+ return
+ endif
+ endfor
endfunction
function! s:app_tags_command() dict
@@ -1122,6 +1110,7 @@ let s:efm_backtrace='%D(in\ %f),'
\.'%\\s%#from\ %f:%l:,'
\.'%\\s#{RAILS_ROOT}/%f:%l:\ %#%m,'
\.'%\\s%##\ %f:%l:%m,'
+ \.'%\\s%##\ %f:%l,'
\.'%\\s%#[%f:%l:\ %#%m,'
\.'%\\s%#%f:%l:\ %#%m,'
\.'%\\s%#%f:%l:,'
@@ -1146,7 +1135,9 @@ function! s:Rake(bang,lnum,arg)
let old_makeprg = &l:makeprg
let old_errorformat = &l:errorformat
try
- if &l:makeprg !~# 'rake'
+ if exists('b:bundler_root') && b:bundler_root ==# rails#app().path()
+ let &l:makeprg = 'bundle exec rake'
+ else
let &l:makeprg = 'rake'
endif
let &l:errorformat = s:efm_backtrace
@@ -1281,9 +1272,9 @@ function! s:readable_default_rake_task(lnum) dict abort
let ver = matchstr(self.name(),'\<db/migrate/0*\zs\d*\ze_')
if ver != ""
let method = self.last_method(lnum)
- if method == "down"
+ if method == "down" || lnum == 1
return "db:migrate:down VERSION=".ver
- elseif method == "up"
+ elseif method == "up" || lnum == line('$')
return "db:migrate:up VERSION=".ver
elseif lnum > 0
return "db:migrate:down db:migrate:up VERSION=".ver
@@ -1697,19 +1688,19 @@ endfunction
function! s:BufNavCommands()
command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rcd :cd `=rails#app().path(<q-args>)`
command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rlcd :lcd `=rails#app().path(<q-args>)`
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rfind :call s:Find(<count>,'<bang>' ,<f-args>)
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find REfind :call s:Find(<count>,'E<bang>',<f-args>)
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RSfind :call s:Find(<count>,'S<bang>',<f-args>)
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RVfind :call s:Find(<count>,'V<bang>',<f-args>)
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RTfind :call s:Find(<count>,'T<bang>',<f-args>)
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rsfind :<count>RSfind<bang> <args>
- command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rtabfind :<count>RTfind<bang> <args>
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit Redit :call s:Edit(<count>,'<bang>' ,<f-args>)
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit REedit :call s:Edit(<count>,'E<bang>',<f-args>)
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RSedit :call s:Edit(<count>,'S<bang>',<f-args>)
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RVedit :call s:Edit(<count>,'V<bang>',<f-args>)
- command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RTedit :call s:Edit(<count>,'T<bang>',<f-args>)
- command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_edit RDedit :call s:Edit(<count>,'<line1>D<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rfind :call s:warn( 'Rfind has been deprecated in favor of :1R or :find' )|call s:Find(<count>,'<bang>' ,<f-args>)
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find REfind :call s:warn('REfind has been deprecated in favor of :1RE or :find')|call s:Find(<count>,'E<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RSfind :call s:warn('RSfind has been deprecated in favor of :1RS or :find')|call s:Find(<count>,'S<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RVfind :call s:warn('RVfind has been deprecated in favor of :1RV or :find')|call s:Find(<count>,'V<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RTfind :call s:warn('RTfind has been deprecated in favor of :1RT or :find')|call s:Find(<count>,'T<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rsfind :call s:warn('Rsfind has been deprecated in favor of :1RS or :sfind')|<count>RSfind<bang> <args>
+ command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rtabfind :call s:warn('Rtabfind has been deprecated in favor of :1RT or :tabfind')|<count>RTfind<bang> <args>
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit Redit :call s:warn( 'Redit has been deprecated in favor of :R')|call s:Edit(<count>,'<bang>' ,<f-args>)
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit REedit :call s:warn('REedit has been deprecated in favor of :RE')|call s:Edit(<count>,'E<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RSedit :call s:warn('RSedit has been deprecated in favor of :RS')|call s:Edit(<count>,'S<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RVedit :call s:warn('RVedit has been deprecated in favor of :RV')|call s:Edit(<count>,'V<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -bang -complete=customlist,s:Complete_edit RTedit :call s:warn('RTedit has been deprecated in favor of :RT')|call s:Edit(<count>,'T<bang>',<f-args>)
+ command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_edit RDedit :call s:warn('RDedit has been deprecated in favor of :RD')|call s:Edit(<count>,'<line1>D<bang>',<f-args>)
command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related A :call s:Alternate('<bang>', <line1>,<line2>,<count>,<f-args>)
command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AE :call s:Alternate('E<bang>',<line1>,<line2>,<count>,<f-args>)
command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AS :call s:Alternate('S<bang>',<line1>,<line2>,<count>,<f-args>)
@@ -1806,8 +1797,7 @@ function! s:Complete_find(ArgLead, CmdLine, CursorPos)
endfor
endif
endfor
- let results = sort(map(keys(seen),'s:sub(v:val,"[.]rb$","")'))
- return s:autocamelize(results,a:ArgLead)
+ return s:autocamelize(sort(keys(seen)),a:ArgLead)
endfunction
function! s:Complete_edit(ArgLead, CmdLine, CursorPos)
@@ -2247,8 +2237,8 @@ function! s:layoutList(A,L,P)
endfunction
function! s:stylesheetList(A,L,P)
- let list = rails#app().relglob('app/assets/stylesheets/','**/*.css*','')
- call map(list,'s:sub(v:val,"\\.css\%(\\.\\w+\)\=$","")')
+ let list = rails#app().relglob('app/assets/stylesheets/','**/*.*','')
+ call map(list,'s:sub(v:val,"\\..*$","")')
let list += rails#app().relglob('public/stylesheets/','**/*','.css')
if rails#app().has('sass')
call extend(list,rails#app().relglob('public/stylesheets/sass/','**/*','.s?ss'))
@@ -2258,8 +2248,8 @@ function! s:stylesheetList(A,L,P)
endfunction
function! s:javascriptList(A,L,P)
- let list = rails#app().relglob('app/assets/javascripts/','**/*.js*','')
- call map(list,'s:sub(v:val,"\\.js\%(\\.\\w+\)*$","")')
+ let list = rails#app().relglob('app/assets/javascripts/','**/*.*','')
+ call map(list,'s:sub(v:val,"\\..*$","")')
let list += rails#app().relglob("public/javascripts/","**/*",".js")
return s:completion_filter(list,a:A)
endfunction
@@ -2626,7 +2616,7 @@ function! s:findview(name)
return pre.name
else
for format in ['.'.s:format('html'), '']
- for type in split(s:view_types,',')
+ for type in s:view_types
if self.app().has_file(pre.name.format.'.'.type)
return pre.name.format.'.'.type
endif
@@ -2687,7 +2677,7 @@ function! s:stylesheetEdit(cmd,...)
elseif rails#app().has('lesscss') && rails#app().has_file('app/stylesheets/'.name.'.less')
return s:EditSimpleRb(a:cmd,"stylesheet",name,"app/stylesheets/",".less",1)
else
- let types = rails#app().relglob('app/assets/stylesheets/'.name,'.css*','')
+ let types = rails#app().relglob('app/assets/stylesheets/'.name,'.*','')
if !empty(types)
return s:EditSimpleRb(a:cmd,'stylesheet',name,'app/assets/stylesheets/',types[0],1)
else
@@ -2703,7 +2693,7 @@ function! s:javascriptEdit(cmd,...)
elseif rails#app().has('coffee') && rails#app().has_file('app/scripts/'.name.'.js')
return s:EditSimpleRb(a:cmd,'javascript',name,'app/scripts/','.js',1)
else
- let types = rails#app().relglob('app/assets/javascripts/'.name,'.js*','')
+ let types = rails#app().relglob('app/assets/javascripts/'.name,'.*','')
if !empty(types)
return s:EditSimpleRb(a:cmd,'javascript',name,'app/assets/javascripts/',types[0],1)
else
@@ -3358,7 +3348,7 @@ function! s:invertrange(beg,end)
endif
let add .= s:mkeep(line)
elseif line =~ '\<remove_index\>'
- let add = s:sub(s:sub(line,'<remove_index','add_index'),':column\s*=>\s*','')
+ let add = s:sub(s:sub(line,'<remove_index','add_index'),':column\s*\=\>\s*','')
elseif line =~ '\<rename_\%(table\|column\|index\)\>'
let add = s:sub(line,'<rename_%(table\s*\(=\s*|%(column|index)\s*\(=\s*[^,]*,\s*)\zs([^,]*)(,\s*)([^,]*)','\3\2\1')
elseif line =~ '\<change_column\>'
@@ -3484,26 +3474,26 @@ endfunction
function! s:helpermethods()
return ""
- \."atom_feed audio_path audio_tag auto_discovery_link_tag auto_link "
- \."button_to button_to_function "
- \."cache capture cdata_section check_box check_box_tag collection_select concat content_for content_tag content_tag_for csrf_meta_tag current_cycle cycle "
- \."date_select datetime_select debug distance_of_time_in_words distance_of_time_in_words_to_now div_for dom_class dom_id draggable_element draggable_element_js drop_receiving_element drop_receiving_element_js "
- \."email_field email_field_tag error_message_on error_messages_for escape_javascript escape_once excerpt "
- \."favicon_link_tag field_set_tag fields_for file_field file_field_tag form form_for form_tag "
+ \."action_name atom_feed audio_path audio_tag auto_discovery_link_tag "
+ \."button_tag button_to button_to_function "
+ \."cache capture cdata_section check_box check_box_tag collection_select concat content_for content_tag content_tag_for controller controller_name controller_path convert_to_model cookies csrf_meta_tag csrf_meta_tags current_cycle cycle "
+ \."date_select datetime_select debug distance_of_time_in_words distance_of_time_in_words_to_now div_for dom_class dom_id "
+ \."email_field email_field_tag escape_javascript escape_once excerpt "
+ \."favicon_link_tag field_set_tag fields_for file_field file_field_tag flash form_for form_tag "
\."grouped_collection_select grouped_options_for_select "
- \."hidden_field hidden_field_tag highlight "
- \."image_path image_submit_tag image_tag input "
- \."javascript_cdata_section javascript_include_tag javascript_path javascript_tag "
- \."l label label_tag link_to link_to_function link_to_if link_to_unless link_to_unless_current localize "
+ \."headers hidden_field hidden_field_tag highlight "
+ \."image_alt image_path image_submit_tag image_tag "
+ \."j javascript_cdata_section javascript_include_tag javascript_path javascript_tag "
+ \."l label label_tag link_to link_to_function link_to_if link_to_unless link_to_unless_current localize logger "
\."mail_to "
\."number_field number_field_tag number_to_currency number_to_human number_to_human_size number_to_percentage number_to_phone number_with_delimiter number_with_precision "
\."option_groups_from_collection_for_select options_for_select options_from_collection_for_select "
- \."password_field password_field_tag path_to_audio path_to_image path_to_javascript path_to_stylesheet path_to_video phone_field phone_field_tag pluralize "
- \."radio_button radio_button_tag range_field range_field_tag raw remote_function reset_cycle "
- \."safe_concat sanitize sanitize_css search_field search_field_tag select select_date select_datetime select_day select_hour select_minute select_month select_second select_tag select_time select_year simple_format sortable_element sortable_element_js strip_links strip_tags stylesheet_link_tag stylesheet_path submit_tag "
- \."t tag telephone_field telephone_field_tag text_area text_area_tag text_field text_field_tag time_ago_in_words time_select time_zone_options_for_select time_zone_select translate truncate "
- \."update_page update_page_tag url_field url_field_tag url_for url_options "
- \."video_path video_tag visual_effect "
+ \."params password_field password_field_tag path_to_audio path_to_image path_to_javascript path_to_stylesheet path_to_video phone_field phone_field_tag pluralize provide "
+ \."radio_button radio_button_tag range_field range_field_tag raw render request request_forgery_protection_token reset_cycle response "
+ \."safe_concat safe_join sanitize sanitize_css search_field search_field_tag select select_date select_datetime select_day select_hour select_minute select_month select_second select_tag select_time select_year session simple_format strip_links strip_tags stylesheet_link_tag stylesheet_path submit_tag "
+ \."t tag telephone_field telephone_field_tag text_area text_area_tag text_field text_field_tag time_ago_in_words time_select time_tag time_zone_options_for_select time_zone_select translate truncate "
+ \."url_field url_field_tag url_for url_options "
+ \."video_path video_tag "
\."word_wrap"
endfunction
@@ -3570,20 +3560,19 @@ function! s:BufSyntax()
syn keyword rubyRailsRenderMethod mail render
syn keyword rubyRailsControllerMethod attachments default helper helper_attr helper_method
endif
- if buffer.type_name('controller','view','helper')
- syn keyword rubyRailsMethod params request response session headers cookies flash
- syn keyword rubyRailsRenderMethod render
- syn keyword rubyRailsMethod logger polymorphic_path polymorphic_url
- endif
if buffer.type_name('helper','view')
+ syn keyword rubyRailsViewMethod polymorphic_path polymorphic_url
exe "syn keyword rubyRailsHelperMethod ".s:gsub(s:helpermethods(),'<%(content_for|select)\s+','')
syn match rubyRailsHelperMethod '\<select\>\%(\s*{\|\s*do\>\|\s*(\=\s*&\)\@!'
syn match rubyRailsHelperMethod '\<\%(content_for?\=\|current_page?\)'
- syn match rubyRailsViewMethod '\.\@<!\<\(h\|html_escape\|u\|url_encode\|controller\)\>'
+ syn match rubyRailsViewMethod '\.\@<!\<\(h\|html_escape\|u\|url_encode\)\>'
if buffer.type_name('view-partial')
syn keyword rubyRailsMethod local_assigns
endif
elseif buffer.type_name('controller')
+ syn keyword rubyRailsMethod params request response session headers cookies flash
+ syn keyword rubyRailsRenderMethod render
+ syn keyword rubyRailsMethod logger polymorphic_path polymorphic_url
syn keyword rubyRailsControllerMethod helper helper_attr helper_method filter layout url_for serialize exempt_from_layout filter_parameter_logging hide_action cache_sweeper protect_from_forgery caches_page cache_page caches_action expire_page expire_action rescue_from
syn keyword rubyRailsRenderMethod head redirect_to render_to_string respond_with
syn match rubyRailsRenderMethod '\<respond_to\>?\@!'
@@ -3605,7 +3594,7 @@ function! s:BufSyntax()
syn keyword rubyRailsTestControllerMethod assert_response assert_redirected_to assert_template assert_recognizes assert_generates assert_routing assert_dom_equal assert_dom_not_equal assert_select assert_select_rjs assert_select_encoded assert_select_email assert_tag assert_no_tag
endif
elseif buffer.type_name('spec')
- syn keyword rubyRailsTestMethod describe context it its specify shared_examples_for it_should_behave_like before after subject fixtures controller_name helper_name
+ syn keyword rubyRailsTestMethod describe context it its specify shared_examples_for it_should_behave_like before after around subject fixtures controller_name helper_name
syn match rubyRailsTestMethod '\<let\>!\='
syn keyword rubyRailsTestMethod violated pending expect double mock mock_model stub_model
syn match rubyRailsTestMethod '\.\@<!\<stub\>!\@!'
@@ -3629,7 +3618,7 @@ function! s:BufSyntax()
syn keyword rubyRailsMethod debugger
syn keyword rubyRailsMethod alias_attribute alias_method_chain attr_accessor_with_default attr_internal attr_internal_accessor attr_internal_reader attr_internal_writer delegate mattr_accessor mattr_reader mattr_writer superclass_delegating_accessor superclass_delegating_reader superclass_delegating_writer
syn keyword rubyRailsMethod cattr_accessor cattr_reader cattr_writer class_inheritable_accessor class_inheritable_array class_inheritable_array_writer class_inheritable_hash class_inheritable_hash_writer class_inheritable_option class_inheritable_reader class_inheritable_writer inheritable_attributes read_inheritable_attribute reset_inheritable_attributes write_inheritable_array write_inheritable_attribute write_inheritable_hash
- syn keyword rubyRailsInclude require_dependency gem
+ syn keyword rubyRailsInclude require_dependency
syn region rubyString matchgroup=rubyStringDelimiter start=+\%(:order\s*=>\s*\)\@<="+ skip=+\\\\\|\\"+ end=+"+ contains=@rubyStringSpecial,railsOrderSpecial
syn region rubyString matchgroup=rubyStringDelimiter start=+\%(:order\s*=>\s*\)\@<='+ skip=+\\\\\|\\'+ end=+'+ contains=@rubyStringSpecial,railsOrderSpecial
@@ -3672,9 +3661,8 @@ function! s:BufSyntax()
exe 'syn keyword '.&syntax.'RailsHelperMethod '.s:gsub(s:helpermethods(),'<%(content_for|select)\s+','').' contained containedin=@'.&syntax.'RailsRegions'
exe 'syn match '.&syntax.'RailsHelperMethod "\<select\>\%(\s*{\|\s*do\>\|\s*(\=\s*&\)\@!" contained containedin=@'.&syntax.'RailsRegions'
exe 'syn match '.&syntax.'RailsHelperMethod "\<\%(content_for?\=\|current_page?\)" contained containedin=@'.&syntax.'RailsRegions'
- exe 'syn keyword '.&syntax.'RailsMethod debugger logger polymorphic_path polymorphic_url contained containedin=@'.&syntax.'RailsRegions'
- exe 'syn keyword '.&syntax.'RailsMethod params request response session headers cookies flash contained containedin=@'.&syntax.'RailsRegions'
- exe 'syn match '.&syntax.'RailsViewMethod "\.\@<!\<\(h\|html_escape\|u\|url_encode\|controller\)\>" contained containedin=@'.&syntax.'RailsRegions'
+ exe 'syn keyword '.&syntax.'RailsMethod debugger polymorphic_path polymorphic_url contained containedin=@'.&syntax.'RailsRegions'
+ exe 'syn match '.&syntax.'RailsViewMethod "\.\@<!\<\(h\|html_escape\|u\|url_encode\)\>" contained containedin=@'.&syntax.'RailsRegions'
if buffer.type_name('view-partial')
exe 'syn keyword '.&syntax.'RailsMethod local_assigns contained containedin=@'.&syntax.'RailsRegions'
endif
@@ -3691,10 +3679,10 @@ function! s:BufSyntax()
syn include @rubyTop syntax/ruby.vim
unlet g:main_syntax
syn cluster yamlRailsRegions contains=yamlRailsOneLiner,yamlRailsBlock,yamlRailsExpression
- syn region yamlRailsOneLiner matchgroup=yamlRailsDelimiter start="^%%\@!" end="$" contains=@rubyRailsTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend oneline
- syn region yamlRailsBlock matchgroup=yamlRailsDelimiter start="<%%\@!" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
- syn region yamlRailsExpression matchgroup=yamlRailsDelimiter start="<%=" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
- syn region yamlRailsComment matchgroup=yamlRailsDelimiter start="<%#" end="%>" contains=rubyTodo,@Spell containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend
+ syn region yamlRailsOneLiner matchgroup=yamlRailsDelimiter start="^%%\@!" end="$" contains=@rubyRailsTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend oneline
+ syn region yamlRailsBlock matchgroup=yamlRailsDelimiter start="<%%\@!" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
+ syn region yamlRailsExpression matchgroup=yamlRailsDelimiter start="<%=" end="%>" contains=@rubyTop containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment
+ syn region yamlRailsComment matchgroup=yamlRailsDelimiter start="<%#" end="%>" contains=rubyTodo,@Spell containedin=ALLBUT,@yamlRailsRegions,yamlRailsComment keepend
syn match yamlRailsMethod '\.\@<!\<\(h\|html_escape\|u\|url_encode\)\>' contained containedin=@yamlRailsRegions
if classes != ''
exe "syn keyword yamlRailsUserClass ".classes." contained containedin=@yamlRailsRegions"
@@ -3813,100 +3801,13 @@ function! rails#log_syntax()
endfunction
" }}}1
-" Statusline {{{1
-
-function! s:addtostatus(letter,status)
- let status = a:status
- if status !~ 'rails' && status !~ '^%!' && g:rails_statusline
- let status=substitute(status,'\C%'.tolower(a:letter),'%'.tolower(a:letter).'%{rails#statusline()}','')
- if status !~ 'rails'
- let status=substitute(status,'\C%'.toupper(a:letter),'%'.toupper(a:letter).'%{rails#STATUSLINE()}','')
- endif
- endif
- return status
-endfunction
-
-function! s:BufInitStatusline()
- if g:rails_statusline
- if &l:statusline == ''
- let &l:statusline = &g:statusline
- endif
- if &l:statusline == ''
- let &l:statusline='%<%f %h%m%r%='
- if &ruler
- let &l:statusline .= '%-14.(%l,%c%V%) %P'
- endif
- endif
- let &l:statusline = s:InjectIntoStatusline(&l:statusline)
- endif
-endfunction
-
-function! s:InitStatusline()
- if g:rails_statusline
- if &g:statusline == ''
- let &g:statusline='%<%f %h%m%r%='
- if &ruler
- let &g:statusline .= '%-16( %l,%c-%v %)%P'
- endif
- endif
- let &g:statusline = s:InjectIntoStatusline(&g:statusline)
- endif
-endfunction
-
-function! s:InjectIntoStatusline(status)
- let status = a:status
- if status !~ 'rails'
- let status = s:addtostatus('y',status)
- let status = s:addtostatus('r',status)
- let status = s:addtostatus('m',status)
- let status = s:addtostatus('w',status)
- let status = s:addtostatus('h',status)
- if status !~ 'rails'
- let status=substitute(status,'%=','%{rails#statusline()}%=','')
- endif
- if status !~ 'rails' && status != ''
- let status .= '%{rails#statusline()}'
- endif
- endif
- return status
-endfunction
-
-function! rails#statusline(...)
- if exists("b:rails_root")
- let t = rails#buffer().type_name()
- if t != "" && a:0 && a:1
- return "[Rails-".t."]"
- else
- return "[Rails]"
- endif
- else
- return ""
- endif
-endfunction
-
-function! rails#STATUSLINE(...)
- if exists("b:rails_root")
- let t = rails#buffer().type_name()
- if t != "" && a:0 && a:1
- return ",RAILS-".toupper(t)
- else
- return ",RAILS"
- endif
- else
- return ""
- endif
-endfunction
-
-" }}}1
" Mappings {{{1
function! s:BufMappings()
- nnoremap <buffer> <silent> <Plug>RailsAlternate :<C-U>A<CR>
- nnoremap <buffer> <silent> <Plug>RailsRelated :<C-U>R<CR>
- nnoremap <buffer> <silent> <Plug>RailsFind :<C-U>REfind<CR>
- nnoremap <buffer> <silent> <Plug>RailsSplitFind :<C-U>RSfind<CR>
- nnoremap <buffer> <silent> <Plug>RailsVSplitFind :<C-U>RVfind<CR>
- nnoremap <buffer> <silent> <Plug>RailsTabFind :<C-U>RTfind<CR>
+ nnoremap <buffer> <silent> <Plug>RailsFind :<C-U>call <SID>Find(v:count1,'E')<CR>
+ nnoremap <buffer> <silent> <Plug>RailsSplitFind :<C-U>call <SID>Find(v:count1,'S')<CR>
+ nnoremap <buffer> <silent> <Plug>RailsVSplitFind :<C-U>call <SID>Find(v:count1,'V')<CR>
+ nnoremap <buffer> <silent> <Plug>RailsTabFind :<C-U>call <SID>Find(v:count1,'T')<CR>
if g:rails_mappings
if !hasmapto("<Plug>RailsFind")
nmap <buffer> gf <Plug>RailsFind
@@ -3917,12 +3818,6 @@ function! s:BufMappings()
if !hasmapto("<Plug>RailsTabFind")
nmap <buffer> <C-W>gf <Plug>RailsTabFind
endif
- if !hasmapto("<Plug>RailsAlternate")
- nmap <buffer> [f <Plug>RailsAlternate
- endif
- if !hasmapto("<Plug>RailsRelated")
- nmap <buffer> ]f <Plug>RailsRelated
- endif
if exists("$CREAM")
imap <buffer> <C-CR> <C-O><Plug>RailsFind
imap <buffer> <M-[> <C-O><Plug>RailsAlternate
@@ -3952,7 +3847,7 @@ function! s:app_dbext_settings(environment) dict
let cmde = '}]; i=0; e=y[e] while e.respond_to?(:to_str) && (i+=1)<16; e.each{|k,v|puts k.to_s+%{=}+v.to_s}}'
let out = self.lightweight_ruby_eval(cmdb.a:environment.cmde)
let adapter = s:extractdbvar(out,'adapter')
- let adapter = get({'mysql2': 'mysql', 'postgresql': 'pgsql', 'sqlite3': 'sqlite', 'sqlserver': 'sqlsrv', 'sybase': 'asa', 'oci': 'ora'},adapter,adapter)
+ let adapter = get({'mysql2': 'mysql', 'postgresql': 'pgsql', 'sqlite3': 'sqlite', 'sqlserver': 'sqlsrv', 'sybase': 'asa', 'oracle': 'ora'},adapter,adapter)
let dict['type'] = toupper(adapter)
let dict['user'] = s:extractdbvar(out,'username')
let dict['passwd'] = s:extractdbvar(out,'password')
@@ -3970,7 +3865,11 @@ function! s:app_dbext_settings(environment) dict
let dict['dbname'] = self.path(dict['dbname'])
endif
let dict['profile'] = ''
- let dict['srvname'] = s:extractdbvar(out,'host')
+ if adapter == 'ora'
+ let dict['srvname'] = s:extractdbvar(out,'database')
+ else
+ let dict['srvname'] = s:extractdbvar(out,'host')
+ endif
let dict['host'] = s:extractdbvar(out,'host')
let dict['port'] = s:extractdbvar(out,'port')
let dict['dsnname'] = s:extractdbvar(out,'dsn')
@@ -4451,37 +4350,14 @@ function! RailsBufInit(path)
let g:RAILS_HISTORY = s:sub(g:RAILS_HISTORY,'%(.{-}\n){,'.g:rails_history_size.'}\zs.*','')
endif
call app.source_callback("config/syntax.vim")
- if &ft == "mason"
- setlocal filetype=eruby
- elseif &ft =~ '^\%(conf\|ruby\)\=$' && expand("%:e") =~ '^\%(rjs\|rxml\|builder\|rake\|mab\)$'
- setlocal filetype=ruby
- elseif &ft =~ '^\%(conf\|ruby\)\=$' && expand("%:t") =~ '^\%(\%(Rake\|Gem\|Cap\)file\|Isolate\)$'
- setlocal filetype=ruby
- elseif &ft =~ '^\%(liquid\)\=$' && expand("%:e") == "liquid"
- setlocal filetype=liquid
- elseif &ft =~ '^\%(haml\|x\=html\)\=$' && expand("%:e") == "haml"
- setlocal filetype=haml
- elseif &ft =~ '^\%(sass\|conf\)\=$' && expand("%:e") == "sass"
- setlocal filetype=sass
- elseif &ft =~ '^\%(scss\|conf\)\=$' && expand("%:e") == "scss"
- setlocal filetype=scss
- elseif &ft =~ '^\%(lesscss\|conf\)\=$' && expand("%:e") == "less"
- setlocal filetype=lesscss
- elseif &ft =~ '^\%(dryml\)\=$' && expand("%:e") == "dryml"
- setlocal filetype=dryml
- elseif (&ft == "" || v:version < 701) && expand("%:e") =~ '^\%(rhtml\|erb\)$'
- setlocal filetype=eruby
- elseif (&ft == "" || v:version < 700) && expand("%:e") == 'yml'
- setlocal filetype=yaml
- elseif &ft =~ '^\%(conf\|yaml\)\=$' && expand("%:t") =~ '\.yml\.example$'
+ if expand('%:t') =~ '\.yml\.example$'
setlocal filetype=yaml
+ elseif expand('%:e') =~ '^\%(rjs\|rxml\|builder\)$'
+ setlocal filetype=ruby
elseif firsttime
" Activate custom syntax
let &syntax = &syntax
endif
- if firsttime
- call s:BufInitStatusline()
- endif
if expand('%:e') == 'log'
nnoremap <buffer> <silent> R :checktime<CR>
nnoremap <buffer> <silent> G :checktime<Bar>$<CR>
@@ -4561,7 +4437,7 @@ function! s:BufSettings()
endif
if has("gui_win32") || has("gui_running")
let code = '*.rb;*.rake;Rakefile'
- let templates = '*.'.s:gsub(s:view_types,',',';*.')
+ let templates = '*.'.join(s:view_types,';*.')
let fixtures = '*.yml;*.csv'
let statics = '*.html;*.css;*.js;*.xml;*.xsd;*.sql;.htaccess;README;README_FOR_APP'
let b:browsefilter = ""
@@ -4573,9 +4449,9 @@ function! s:BufSettings()
\."All Files (*.*)\t*.*\n"
endif
call self.setvar('&includeexpr','RailsIncludeexpr()')
- call self.setvar('&suffixesadd', ".rb,.".s:gsub(s:view_types,',',',.').",.css,.js,.yml,.csv,.rake,.sql,.html,.xml")
+ call self.setvar('&suffixesadd', ".rb,.".join(s:view_types,',.'))
let ft = self.getvar('&filetype')
- if ft =~ '^\%(e\=ruby\|[yh]aml\|javascript\|css\|s[ac]ss\|lesscss\)$'
+ if ft =~ '^\%(e\=ruby\|[yh]aml\|coffee\|css\|s[ac]ss\|lesscss\)$'
call self.setvar('&shiftwidth',2)
call self.setvar('&softtabstop',2)
call self.setvar('&expandtab',1)
@@ -4584,7 +4460,6 @@ function! s:BufSettings()
endif
endif
if ft == 'ruby'
- call self.setvar('&suffixesadd',".rb,.".s:gsub(s:view_types,',',',.').",.yml,.csv,.rake,s.rb")
call self.setvar('&define',self.define_pattern())
" This really belongs in after/ftplugin/ruby.vim but we'll be nice
if exists('g:loaded_surround') && self.getvar('surround_101') == ''
@@ -4594,9 +4469,7 @@ function! s:BufSettings()
endif
elseif ft == 'yaml' || fnamemodify(self.name(),':e') == 'yml'
call self.setvar('&define',self.define_pattern())
- call self.setvar('&suffixesadd',".yml,.csv,.rb,.".s:gsub(s:view_types,',',',.').",.rake,s.rb")
elseif ft =~# '^eruby\>'
- call self.setvar('&suffixesadd',".".s:gsub(s:view_types,',',',.').",.rb,.css,.js,.html,.yml,.csv")
if exists("g:loaded_allml")
call self.setvar('allml_stylesheet_link_tag', "<%= stylesheet_link_tag '\r' %>")
call self.setvar('allml_javascript_include_tag', "<%= javascript_include_tag '\r' %>")
@@ -4664,8 +4537,8 @@ augroup railsPluginAuto
autocmd BufWritePost */generators/** call rails#cache_clear("generators")
autocmd FileType * if exists("b:rails_root") | call s:BufSettings() | endif
autocmd Syntax ruby,eruby,yaml,haml,javascript,coffee,railslog if exists("b:rails_root") | call s:BufSyntax() | endif
- autocmd QuickFixCmdPre make* call s:push_chdir()
- autocmd QuickFixCmdPost make* call s:pop_command()
+ autocmd QuickFixCmdPre *make* call s:push_chdir()
+ autocmd QuickFixCmdPost *make* call s:pop_command()
augroup END
" }}}1
View
175 bundle/rails/doc/rails.txt
@@ -1,11 +1,8 @@
*rails.txt* Plugin for working with Ruby on Rails applications
-Author: Tim Pope <vimNOSPAM@tpope.org> |rails-plugin-author|
+Author: Tim Pope <http://tpo.pe/>
|rails-introduction| Introduction and Feature Summary
-|rails-installation| Installation and Usage
-|rails-configure-vim| Configuring Vim
-|rails-install-plugin| Installing and Using the Plugin
|rails-commands| General Commands
|rails-navigation| Navigation
|rails-gf| File Under Cursor - gf
@@ -34,80 +31,6 @@ This plugin is only available if 'compatible' is not set.
INTRODUCTION *rails-introduction* *rails*
-TextMate may be the latest craze for developing Ruby on Rails applications,
-but Vim is forever. This plugin offers the following features for Ruby on
-Rails application development.
-
-1. Automatically detects buffers containing files from Rails applications,
- and applies settings to those buffers (and only those buffers). You can
- use an autocommand to apply your own custom settings as well.
- |rails-configuration|
-
-2. Unintrusive. Only files in a Rails application should be affected; regular
- Ruby scripts are left untouched. Even when enabled, the plugin should keep
- out of your way if you're not using its features. (If you find a situation
- where this is not a case, contact the |rails-plugin-author|.)
-
-3. Easy navigation of the Rails directory structure. |gf| considers context
- and knows about partials, fixtures, and much more. There are two commands,
- :A (alternate) and :R (related) for easy jumping between files, including
- favorites like model to migration, template to helper, and controller to
- functional test. For more advanced usage, :Rmodel, :Rview, :Rcontroller,
- and several other commands are provided. |rails-navigation|
-
-4. Enhanced syntax highlighting. From has_and_belongs_to_many to
- distance_of_time_in_words, it's here. For easy completion of these long
- method names, 'completefunc' is set to enable syntax based completion on
- |i_CTRL-X_CTRL-U|. |rails-syntax|
-
-5. Interface to rake. Use :Rake to run the current test, spec, or feature.
- Use :.Rake to do a focused run of just the method, example, or scenario on
- the current line. :Rake can also run arbitrary migrations, load individual
- fixtures, and more. |rails-rake|
-
-6. Interface to script/*. Generally, use ":Rscript about" to call
- "script/about" or "script/rails about". Most commands have wrappers with
- additional features: ":Rgenerate controller Blog" generates a blog
- controller and edits app/controllers/blog_controller.rb. |rails-scripts|
-
-7. Partial extraction and migration inversion. |:Rextract| {file} replaces
- the desired range (ideally selected in visual line mode) with "render
- :partial => '{file}'", which is automatically created with your content.
- The @{file} instance variable is replaced with the {file} local variable.
- |:Rinvert| takes a self.up migration and writes a self.down.
- |rails-refactoring|
-
-8. Integration with other plugins. |:Rtree| spawns NERDTree.vim. If
- dbext.vim is installed, it will be transparently configured to reflect
- database.yml. Cream users get some additional mappings, and all GUI users
- get a menu. |rails-integration|
-
-INSTALLATION AND USAGE *rails-installation*
-
-If you are familiar Vim and have the latest version installed, you may skip
-directly to |rails-install-plugin| below.
-
-Configuring Vim ~
- *rails-configure-vim*
-If you are new to Vim, you need to create a vimrc. For Windows, this file
-goes in ~\_vimrc (try :e ~\_vimrc if you don't know where this is). On other
-platforms, use ~/.vimrc. A very minimal example file is shown below.
->
- set nocompatible
- syntax on
- filetype plugin indent on
->
-Installing and Using the Plugin ~
- *rails-install-plugin*
-If you have the zip file, extract it to vimfiles (Windows) or ~/.vim
-(everything else). You should have the following files: >
- autoload/rails.vim
- plugin/rails.vim
- doc/rails.txt
-See |add-local-help| for instructions on enabling the documentation. In a
-nutshell: >
- :helptags ~/.vim/doc
-
Whenever you edit a file in a Rails application, this plugin will be
automatically activated. This sets various options and defines a few
buffer-specific commands.
@@ -147,10 +70,10 @@ actually edit a file from a Rails application.
|:help| rails.
*rails-:Redit*
-:Redit {file} Edit {file}, relative to the application root. Append
- :line or #method to jump within the file, as in
- :Redit app/controllers/users_controller.rb:12 or
- :Redit app/models/user.rb#activate .
+:Redit {file} Deprecated in favor of |:R|.
+
+ *rails-:Rfind*
+:Rfind [{file}] Deprecated in favor of |:R| or |:find|.
*rails-:Rlog*
:Rlog [{logfile}] Split window and open {logfile} ($RAILS_ENV or
@@ -221,19 +144,13 @@ following features will greatly ease navigating the Rails file structure.
The 'path' has been modified to include all the best places to be.
>
- :find blog_controller
- :find book_test
+ :find application_controller.rb
<
- *rails-:Rfind*
-:Rfind [{file}] Find {file}. Very similar to :find, but things like
- BlogController are properly handled, and tab complete
- works.
-
File Under Cursor - gf ~
*rails-gf*
The |gf| command, which normally edits the current file under the cursor, has
-been remapped to take context into account. |CTRL-W_f|(open in new window) and
-|CTRL-W_gf| (open in new tab) are also remapped.
+been remapped to take context into account. |CTRL-W_f| (open in new window)
+and |CTRL-W_gf| (open in new tab) are also remapped.
Example uses of |gf|, and where they might lead.
(* indicates cursor position)
@@ -284,15 +201,17 @@ Two commands, :A and :R, are used quickly jump to an "alternate" and a
:AS either the same window (:A and :AE), a new split
:AV window (:AS), a new vertically split window (:AV), a
:AT new tab (:AT), or read it into the current buffer
-:AD (:AD). A mapping for :A is [f .
+:AD (:AD).
*rails-:R* *rails-:RE* *rails-:RS* *rails-:RV* *rails-:RT* *rails-:RD*
:R These are similar |rails-:A| and friends above, only
:RE they jump to the "related" file rather than the
-:RS "alternate." A mapping for :R is ]f .
-:RV
-:RT
-:RD
+:RS "alternate." With a file name argument, they edit
+:RV a file relative to the application root (:R Rakefile),
+:RT and with a count and a file name argument, they find a
+:RD file in 'path' (e.g., :1R PostsController.) You can
+ also append a line number (post.rb:42) or a method
+ (PostsController#32) to both forms.
*rails-alternate* *rails-related*
The alternate file is most frequently the test file, though there are
@@ -331,8 +250,8 @@ opening in a new tab, and reading the file into the current buffer. For
:Rmodel, those variants would be :RSmodel, :RVmodel, :RTmodel, and :RDmodel.
There is also :REmodel which is a synonym for :Rmodel (future versions might
allow customization of the behavior of :Rmodel). They also allow for jumping
-to methods or line numbers using the same syntax as |:Redit|, and file
-creation can be forced by adding a ! after the filename (not after the command
+to methods or line numbers using the same syntax as |:R|, and file creation
+can be forced by adding a ! after the filename (not after the command
itself!).
:Rcontroller |rails-:Rcontroller|
@@ -523,12 +442,13 @@ RAKE *rails-rake*
Rake integration happens through the :Rake command.
*rails-:Rake*
-:[range]Rake {targets} Calls |:make!| {targets} (with 'makeprg' being rake)
- and opens the quickfix window if there were any
- errors. An argument of "-" reruns the last task. If
- {targets} are omitted, :Rake defaults to something
- sensible as described below. Giving a line number
- argument may affect that default.
+:[range]Rake {targets} Calls |:make!| {targets} (with 'makeprg' being rake,
+ or `bundle exec rake` if bundler.vim is active) and
+ opens the quickfix window if there were any errors.
+ An argument of "-" reruns the last task. If {targets}
+ are omitted, :Rake defaults to something sensible as
+ described below. Giving a line number argument may
+ affect that default.
*rails-:Rake!*
:[range]Rake! {targets} Called with a bang, :Rake will forgo opening the
@@ -914,10 +834,6 @@ others. This allows shortening the above example: >
*rails-'includeexpr'* *rails-'inex'*
The 'includeexpr' option is set to enable the magic described in |rails-gf|.
- *rails-'statusline'* *rails-'stl'*
-Useful information is added to the 'statusline', when |g:rails_statusline| is
-enabled.
-
*rails-'filetype'* *rails-'ft'*
The 'filetype' is sometimes adjusted for Rails files. Most notably, *.rxml
and *.rjs are treated as Ruby files, and files that have been falsely
@@ -1033,8 +949,7 @@ JavaScript files, since ctags has a tendency to choke on those.
*g:rails_default_file* >
let g:rails_default_file='config/database.yml'
-File to load when a new Rails application is created, or when loading an
-existing project from the menu. Defaults to the README.
+File to load when a new Rails application is created. Defaults to the README.
*rails-screen* *g:rails_gnu_screen* >
let g:rails_gnu_screen=1
@@ -1063,22 +978,14 @@ Modelines are deprecated and disabled by default.
*g:rails_menu* >
let g:rails_menu=1
When 2, a Rails menu is created. When 1, this menu is a submenu under the
-Plugin menu. The default is 1 except on MacVim, where reports of weird
-terminal output have led to it being disabled by default.
+Plugin menu. The default is 0, as the menu is slated for removal from future
+versions of rails.vim.
*g:rails_url* >
let g:rails_url='http://localhost:3000/'
Used for the |:Rpreview| command. Default is as shown above. Overridden by
b:rails_url.
- *g:rails_statusline* >
- let g:rails_statusline=1
-Give a clue in the statusline when this plugin is enabled. Enabled by
-default. This used to be a far more verbose indicator which included the
-type of Rails file. If you actually liked this, you can add either
-%{rails#statusline(1)} or %{rails#STATUSLINE(1)} to 'statusline' explicitly
-(and let the author know, because this fallback is likely getting the boot).
-
*g:rails_syntax* >
let g:rails_syntax=1
When enabled, this tweaks the syntax highlighting to be more Rails friendly.
@@ -1096,34 +1003,18 @@ This is highly discouraged: don't fight Rails.
ABOUT *rails-about* *rails-plugin-author*
-This plugin was written by Tim Pope. Email him at <vimNOSPAM@tpope.org>. He
-can also be found on Freenode's IRC network, hanging out in #rubyonrails and
-#vim as tpope.
+This plugin was written by Tim Pope. Email all comments, complaints, and compliments to him at vim at tpope. org.
-The official homepage is
- http://rails.vim.tpope.net
The latest stable version can be found at
http://www.vim.org/scripts/script.php?script_id=1567
-You can keep up to date with |GetLatestVimScripts|.
-The very latest development versions can be retrieved from Git:
- http://github.com/tpope/vim-rails
+Bugs can be reported and the very latest development version can be retrieved
+from GitHub:
+ https://github.com/tpope/vim-rails
git clone git://github.com/tpope/vim-rails.git
-The Github repository has Pledgie donations enabled. All donations made will
-proxied along to ICCF, which goes to help needy children in |Uganda|.
-Donations will be made in through the plugin author's vim.org account through
-http://www.vim.org/sponsor/ . The voting privileges associated with the
-donation will be used to vote for features that will enable better plugins in
-the future. If you would rather keep those voting privileges for yourself, or
-you want your donation to be tax deductible, donate directly through vim.org
-instead. Donations have historically been matched.
-
-Feedback is highly desired on this plugin. Please send all comments,
-complaints, and compliments to the author. No bug is too small to report.
-
*rails-license*
-This plugin is distributable under the same terms as Vim itself. See
-|license|. No warranties, expressed or implied.
+Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
+See |license|.
vim:tw=78:ts=8:ft=help:norl:
View
5 bundle/rails/plugin/rails.vim
@@ -1,7 +1,6 @@
" rails.vim - Detect a rails application
-" Author: Tim Pope <vimNOSPAM@tpope.org>
+" Author: Tim Pope <http://tpo.pe/>
" GetLatestVimScripts: 1567 1 :AutoInstall: rails.vim
-" URL: http://rails.vim.tpope.net/
" Install this file as plugin/rails.vim. See doc/rails.txt for details. (Grab
" it from the URL above if you don't have it.) To access it from Vim, see
@@ -60,7 +59,7 @@ call s:SetOptDefault("rails_ctags_arguments","--languages=-javascript")
call s:SetOptDefault("rails_default_file","README")
call s:SetOptDefault("rails_root_url",'http://localhost:3000/')
call s:SetOptDefault("rails_modelines",0)
-call s:SetOptDefault("rails_menu",!has('mac'))
+call s:SetOptDefault("rails_menu",0)
call s:SetOptDefault("rails_gnu_screen",1)
call s:SetOptDefault("rails_history_size",5)
call s:SetOptDefault("rails_generators","controller\ngenerator\nhelper\nintegration_test\nmailer\nmetal\nmigration\nmodel\nobserver\nperformance_test\nplugin\nresource\nscaffold\nscaffold_controller\nsession_migration\nstylesheets")

0 comments on commit 3333cc2

Please sign in to comment.