new rails.vim 4.0

This commit is contained in:
Hunter Haugen 2009-11-03 19:14:03 +05:30
parent af75f133e9
commit 6078c736da
7 changed files with 2267 additions and 1955 deletions

File diff suppressed because it is too large Load diff

View file

@ -14,6 +14,7 @@ Author: Tim Pope <vimNOSPAM@tpope.info> |rails-plugin-author|
|rails-controller-navigation| Controller Navigation Commands
|rails-misc-navigation| Miscellaneous Navigation Commands
|rails-custom-navigation| Custom Navigation Commands
|rails-rake| Rake
|rails-scripts| Script Wrappers
|rails-refactoring| Refactoring Helpers
|rails-partials| Partial Extraction
@ -50,22 +51,22 @@ Rails application development.
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. Provides reasonable settings for working with Rails applications. Rake is
the 'makeprg' (and it always knows where your Rakefile is), 'shiftwidth'
is 2, and 'path' includes an appropriate collection of directories from
your application. |rails-options|
4. Easy navigation of the Rails directory structure. |gf| considers context
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|
5. Enhanced syntax highlighting. From has_and_belongs_to_many to
distance_of_time_in_words, it's here. For Vim 7 users, 'completefunc' is
set to enable syntax based completion on |i_CTRL-X_CTRL-U|, making it easy
to complete such long method names. |rails-syntax|
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". Most commands have wrappers with additional features:
@ -79,10 +80,10 @@ Rails application development.
|:Rinvert| takes a self.up migration and writes a self.down.
|rails-refactoring|
8. Integration with other plugins. |:Rproject| creates a new project.vim
project. |:Rdbext| loads database settings from database.yml for dbext.vim
(and this happens by default under most circumstances). Cream users get
some additional mappings, and all GUI users get a menu. |rails-integration|
8. Integration with other plugins. |:Rtree| spawns NERDTree.vim or creates a
new project.vim project. 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*
@ -92,21 +93,17 @@ directly to |rails-install-plugin| below.
Installing and Configuring Vim ~
*rails-install-vim*
Because it is common for users to utilize an older version of Vim that came
installed on a system, rails.vim has a design goal of remaining compatible
with versions of Vim 6.2 and newer. However, if you have a choice in the
matter, you are strongly encouraged to install the latest version available.
Older versions of Vim should work, but increasingly, new plugin features will
require Vim 7 or newer. If possible, install a version of Vim with the |Ruby|
interface compiled in, as a few features will make use of it when available.
Vim 7 or newer is required. If possible, install a version of Vim with the
|Ruby| interface compiled in, as a few features will make use of it when
available.
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
set nocompatible
syntax on
filetype plugin indent on
>
Installing and Using the Plugin ~
*rails-install-plugin*
@ -138,16 +135,9 @@ actually edit a file from a Rails application.
:Rails {directory} The only global command. Creates a new Rails
application in {directory}, and loads the README.
*rails-:Rake*
:Rake {targets} Like calling |:make| {targets} (with 'makeprg' being
rake). However, in some contexts, if {targets} are
omitted, :Rake defaults to something sensible (like
db:migrate in a migration, or your current test).
*rails-:Rake!*
:Rake! {targets} Called with a bang, :Rake will use an alternate
'errorformat' which attempts to parse the full stack
backtrace.
:Rails! Show the version of rails.vim installed. If rails.vim
is active for the current buffer, also show the type
of Rails file detected.
*rails-:Rcd*
:Rcd [{directory}] |:cd| to /path/to/railsapp/{directory}.
@ -166,7 +156,10 @@ actually edit a file from a Rails application.
|:help| rails.
*rails-:Redit*
:Redit {file} Edit {file}, relative to the application root.
: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 .
*rails-:Rlog*
:Rlog [{logfile}] Split window and open {logfile} ($RAILS_ENV or
@ -182,21 +175,27 @@ actually edit a file from a Rails application.
*rails-:Rpreview*
:Rpreview [{path}] Creates a URL from http://localhost:3000/ and the
{path} given. If {path} is omitted, a sensible
default is used (considers the current
controller/template, but does not take routing into
account). The not too useful default is to then edit
this URL using Vim itself, allowing |netrw| to
{path} given. The not too useful default is to then
edit this URL using Vim itself, allowing |netrw| to
download it. More useful is to define a :OpenURL
command, which will be used instead (see
|rails-:OpenURL|).
|rails-:OpenURL|). If {path} is omitted, a sensible
default is used (considers the current
controller/template, but does not take routing into
account). The default is overridden by comments like
the following that are either before the current
method call or at the top of the file: >
# GET /users
# PUT /users/1
<
*rails-:Rpreview!*
:Rpreview! [{path}] As with :Rpreview, except :OpenURL is never used.
*rails-:Rtags*
:Rtags Calls ctags -R on the current application root.
Exuberant ctags must be installed.
:Rtags Calls ctags -R on the current application root and
writes the result to tmp/tags. Exuberant ctags must
be installed. Additional arguments can be passed to
ctags with |g:rails_ctags_arguments|.
*rails-:Rrefresh*
:Rrefresh Refreshes certain cached settings. Most noticeably,
@ -237,8 +236,7 @@ The 'path' has been modified to include all the best places to be.
<
*rails-:Rfind*
:Rfind [{file}] Find {file}. Very similar to :find, but things like
BlogController are properly handled, and if
genutils.vim is installed (1.x not 2.x), tab complete
BlogController are properly handled, and tab complete
works. The default filename is taken from under the
cursor in a manner quite similar to gf, described
below.
@ -262,7 +260,7 @@ Example uses of |gf|, and where they might lead.
< app/controllers/blog_controller.rb ~
>
<%= render :partial => 'sh*ared/sidebar' %>
< app/views/shared/_sidebar.rhtml ~
< app/views/shared/_sidebar.html.erb ~
>
<%= stylesheet_link_tag :scaf*fold %>
< public/stylesheets/scaffold.css ~
@ -277,7 +275,7 @@ Example uses of |gf|, and where they might lead.
< test/fixtures/posts.yml ~
>
layout :pri*nt
< app/views/layouts/print.rhtml ~
< app/views/layouts/print.html.erb ~
>
<%= link_to "New", new_comme*nt_path %>
< app/controllers/comments_controller.rb (jumps to def new) ~
@ -292,33 +290,35 @@ Alternate and Related Files ~
Two commands, :A and :R, are used quickly jump to an "alternate" and a
"related" file, defined below.
*rails-:A* *rails-:AE* *rails-:AS* *rails-:AV* *rails-:AT*
*rails-:A* *rails-:AE* *rails-:AS* *rails-:AV* *rails-:AT* *rails-:AD*
:A These commands were picked to mimic Michael Sharpe's
:AE a.vim. Briefly, they edit the "alternate" file, in
:AS either the same window (:A and :AE), a new split
:AV window (:AS), a new vertically split window (:AV), or
:AT a new tab (:AT). A mapping for :A is [f .
: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 .
*rails-:R* *rails-:RE* *rails-:RS* *rails-:RV* *rails-:RT*
*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
*rails-alternate* *rails-related*
The alternate file is most frequently the test file, though there are
exceptions. The related file varies, and is sometimes dependent on current
current location in the file. For example, when editing a controller, the
related file is template for the method currently being edited.
location in the file. For example, when editing a controller, the related
file is template for the method currently being edited.
The easiest way to learn these commands is to experiment. A few examples of
alternate and related files follow:
alternate and related files for a Test::Unit application follow:
Current file Alternate file Related file ~
model unit test related migration
model unit test schema definition
controller (in method) functional test template (view)
template (view) helper controller (jump to method)
template (view) functional test controller (jump to method)
migration previous migration next migration
config/routes.rb config/database.yml config/environment.rb
@ -330,15 +330,17 @@ For the less common cases, a more deliberate set of commands are provided.
Each of the following takes an optional argument (with tab completion) but
defaults to a reasonable guess that follows Rails conventions. For example,
when editing app/models/employee.rb, :Rcontroller will default to
app/controllers/employees_controller.rb. The controller and model options,
ideally set from |rails-modelines|, can override the mapping from model
related files to controller related files (Rset controller=hiring) and vice
versa (Rset model=employee). See |rails-:Rset|.
app/controllers/employees_controller.rb. The controller and model options
can override the mapping from model related files to controller related files
(Rset controller=hiring) and vice versa (Rset model=employee). See
|rails-:Rset|.
Each of the following commands has variants for splitting, vertical splitting
and opening in a new tab. For :Rmodel, those variants would be :RSmodel,
:RVmodel, and :RTmodel. There is also :REmodel which is a synonym for :Rmodel
(future versions might allow customization of the behavior of :Rmodel).
Each of the following commands has variants for splitting, vertical splitting,
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|.
Model Navigation Commands ~
@ -346,8 +348,7 @@ Model Navigation Commands ~
The default for model navigation commands is the current model, if it can be
determined. For example, test/unit/post_test.rb would have a current model
of post. Otherwise, if a controller name can be determined, said controller
name will be singularized and used. To override this, use a command or
modeline like: >
name will be singularized and used. To override this, use a command like: >
Rset model=comment
:Rmodel |rails-:Rmodel|
@ -363,10 +364,9 @@ modeline like: >
:Rmigration [{pattern}] If {pattern} is a number, find the migration for that
particular set of digits, zero-padding if necessary.
Otherwise, find the newest migration containing the
given pattern. The pattern defaults to the current
model name, pluralized. So when editing the Post
model, :Rmigration with no arguments might find
create_posts.rb, or add_date_to_posts.rb.
given pattern. Omitting the pattern selects the
latest migration. Give a numeric argument of 0 to edit
db/schema.rb.
*rails-:Robserver*
:Robserver [{name}] Find the observer with a name like
@ -386,7 +386,8 @@ modeline like: >
between YAML and CSV fixtures.
*rails-:Runittest*
:Runittest [{name}] Edit the unit test for the specified model.
:Runittest [{name}] Edit the unit test or model spec for the specified
model.
Controller Navigation Commands ~
*rails-controller-navigation*
@ -394,7 +395,7 @@ The default for controller navigation commands is the current controller, if
it can be determined. For example, test/functional/blog_test.rb would have a
current controller of blog. Otherwise, if a model name can be determined,
said model name will be pluralized and used. To override this, use a command
or modeline like: >
like: >
Rset controller=blog
:Rcontroller |rails-:Rcontroller|
@ -423,14 +424,14 @@ or modeline like: >
that cannot be found. A new layout will be created if
an extension is given.
*rails-:Rapi*
:Rapi [{name}] Edit the API for the specified controller. This
command is deprecated; add it yourself with
|:Rcommand| if you still desire it.
*rails-:Rfunctionaltest*
:Rfunctionaltest [{name}]
Edit the functional test for the specified controller.
Edit the functional test or controller spec for the
specified controller.
*rails-:Rapi*
:Rapi [{name}] This command is obsolete; add it yourself with
|:Rnavcommand| if you still desire it.
Miscellaneous Navigation Commands ~
*rails-misc-navigation*
@ -442,7 +443,12 @@ The following commands are not clearly associated with models or controllers.
:Rplugin |rails-:Rplugin|
:Rlib |rails-:Rlib|
:Rtask |rails-:Rtask|
:Rmetal |rails-:Rmetal|
:Renvironment |rails-:Renvironment|
:Rinitializer |rails-:Rinitializer|
:Rlocale |rails-:Rlocale|
:Rintegrationtest |rails-:Rintegrationtest|
:Rspec |rails-:Rspec|
*rails-:Rstylesheet*
:Rstylesheet [{name}] Edit the stylesheet for the specified name, defaulting
@ -458,10 +464,11 @@ The following commands are not clearly associated with models or controllers.
is omitted, it defaults to init.rb.
*rails-:Rlib*
:Rlib {name} Edit the library from the lib directory for the
:Rlib [{name}] Edit the library from the lib directory for the
specified name. If the current file is part of a
plugin, the libraries from that plugin can be
specified as well.
specified as well. With no argument, defaults to
editing config/routes.rb.
*rails-:Rtask*
:Rtask [{name}] Edit the .rake file from lib/tasks for the specified
@ -470,11 +477,36 @@ The following commands are not clearly associated with models or controllers.
argument is given, either the current plugin's
Rakefile or the application Rakefile will be edited.
*rails-:Rmetal*
:Rmetal [{name}] Edit the app/metal file specified. With no argument,
defaults to editing config/boot.rb.
*rails-:Renvironment*
:Renvironment [{name}] Edit the config/environments file specified. With no
argument, defaults to editing config/environment.rb.
*rails-:Rinitializer*
:Rinitializer [{name}] Edit the config/initializers file specified. With no
argument, defaults to editing config/routes.rb.
*rails-:Rlocale*
:Rlocale [{name}] Edit the config/locale file specified, optionally
adding a yml or rb extension if none is given. With
no argument, checks config/environment.rb for the
default locale.
*rails-:Rintegrationtest*
:Rintegrationtest [{name}]
Edit the integration test specified. The default
is based on the current controller or model, with no
singularization or pluralization done.
Edit the integration test, integration spec, or
cucumber feature specified. With no argument,
defaults to editing test/test_helper.rb.
*rails-:Rspec*
:Rspec [{name}] Edit the given spec. With no argument, defaults to
editing spec/spec_helper.rb (If you want to jump to
the spec for the given file, use |:A| instead). This
command is only defined if there is a spec folder in
the root of the application.
Custom Navigation Commands ~
*rails-custom-navigation*
@ -483,8 +515,8 @@ It is also possible to create custom navigation commands. This is best done
in an initialization routine of some sort (e.g., an autocommand); see
|rails-configuration| for details.
*rails-:Rcommand*
:Rcommand [options] {name} [{path} ...]
*rails-:Rnavcommand*
:Rnavcommand [options] {name} [{path} ...]
Create a navigation command with the supplied
name, looking in the supplied paths, using the
supplied options. The -suffix option specifies what
@ -498,18 +530,78 @@ in an initialization routine of some sort (e.g., an autocommand); see
model, controller, or both (as with :Rintegrationtest)
is used as a default.
:Rcommand is still under development and far from fully documented, but the
following examples should illustrate the basics:
>
Rcommand api app/apis -glob=**/* -suffix=_api.rb
Rcommand config config -glob=*.* -suffix= -default=routes.rb
Rcommand environment config/environments -default=../environment
Rcommand concern app/concerns -glob=**/*
*rails-:Rcommand*
:Rcommand Obsolete alias for |:Rnavcommand|.
Examples: >
Rnavcommand api app/apis -glob=**/* -suffix=_api.rb
Rnavcommand config config -glob=*.* -suffix= -default=routes.rb
Rnavcommand concern app/concerns -glob=**/*
Rnavcommand exemplar test/exemplars spec/exemplars -glob=**/*
\ -default=model() -suffix=_exemplar.rb
Finally, one Vim feature that proves helpful in conjunction with all of the
above is |CTRL-^|. This keystroke edits the previous file, and is helpful to
back out of any of the above commands.
==============================================================================
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. 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
quickfix window.
*rails-rake-defaults*
Generally, the default task is one that runs the test you'd expect. For
example, if you're in a view in an RSpec application, the view spec is run,
but if it's a Test::Unit application, the functional test for the
corresponding controller is run. The following table lists the most
interesting mappings:
File Task ~
unit test test:units TEST=...
functional test test:functionals TEST=...
integration test test:integration TEST=...
spec spec SPEC=...
feature cucumber FEATURE=...
model test:units TEST=... spec SPEC=...
controller test:functionals TEST=... spec SPEC=...
helper test:functionals TEST=... spec SPEC=...
view test:functionals TEST=... spec SPEC=...
fixtures db:fixtures:load FIXTURES=...
migration db:migrate VERSION=...
config/routes.rb routes
db/seeds.rb db:seed
Additionally, when :Rake is given a line number (e.g., :.Rake), the following
additional tasks can be invoked:
File Task ~
unit test test:units TEST=... TESTOPTS=-n...
functional test test:functionals TEST=... TESTOPTS=-n...
integration test test:integration TEST=... TESTOPTS=-n...
spec spec SPEC=... SPEC_OPTS=--line=...
feature cucumber FEATURE=...:...
controller routes CONTROLLER=...
fixtures db:fixtures:identify LABEL=...
migration in self.up db:migrate:up VERSION=...
migration in self.down db:migrate:down VERSION=...
migration elsewhere db:migrate:redo VERSION=...
task ... (try to guess currently edited declaration)
Finally, you can override the default task with a comment like "# rake ..."
before the method pointed to by [range] or at the top of the file.
==============================================================================
SCRIPT WRAPPERS *rails-scripts*
@ -519,13 +611,11 @@ A limited amount of completion with <Tab> is supported.
*rails-:Rscript*
:Rscript {script} {options}
Call ruby script/{script} {options}.
Call ruby script/{script} {options}. Defaults to
calling script/console.
*rails-:Rconsole*
:Rconsole {options} Start script/console. On Windows it will be launched
in the background with |!start|. In the terminal
version GNU Screen is used if it is running and
|g:rails_gnu_screen| is set.
:Rconsole {options} Obsolete. Call |:Rscript| instead.
*rails-:Rrunner*
:[range]Rrunner {code} Executes {code} with script/runner. Differs from
@ -546,11 +636,10 @@ A limited amount of completion with <Tab> is supported.
*rails-:Rgenerate*
:Rgenerate {options} Calls script/generate {options}, and then edits the
first file generated. Respects |g:rails_subversion|.
first file generated.
*rails-:Rdestroy*
:Rdestroy {options} Calls script/destroy {options}. Respects
|g:rails_subversion|.
:Rdestroy {options} Calls script/destroy {options}.
*rails-:Rserver*
:Rserver {options} Launches script/server {options} in the background.
@ -579,9 +668,9 @@ The :Rextract command can be used to extract a partial to a new file.
*rails-:Rpartial*
:[range]Rpartial [{controller}/]{name}
Deprecated alias for :Rextract.
Obsolete alias for :Rextract.
If this is your file, in app/views/blog/show.rhtml: >
If this is your file, in app/views/blog/show.html.erb: >
1 <div>
2 <h2><%= @post.title %></h2>
@ -598,7 +687,7 @@ Your file will change to this: >
2 <%= render :partial => 'post' %>
3 </div>
And app/views/blog/_post.rhtml will now contain: >
And app/views/blog/_post.html.erb will now contain: >
1 <h2><%= post.title %></h2>
2 <p><%= post.body %></p>
@ -640,42 +729,26 @@ A handful of Vim plugins are enhanced by rails.vim. All plugins mentioned can
be found at http://www.vim.org/. Cream and GUI menus (for lack of a better
place) are also covered in this section.
*rails-:Rproject* *rails-project*
:Rproject [{file}] This command is only provided when the |project|
plugin is installed. Invoke :Project (typically
without an argument), and search for the root of the
current Rails application. If it is not found, create
a new project, with appropriate directories (app,
etc., but not vendor).
*rails-:Rproject!*
:Rproject! [{file}] Same as :Rproject, only delete existing project if it
exists and recreate it. The logic to delete the old
project is convoluted and possibly erroneous; report
any problems to the |rails-plugin-author|. A handy
mapping might look something like: >
autocmd User Rails map <buffer> <F6> :Rproject!|silent w<CR>
< As a bonus, this command organizes views into separate
directories for easier navigation. The downside of
this is that you will have to regenerate your project
each time you add another view directory (which is why
this command recreates your project each time!).
*rails-:Rtree* *rails-:Rproject*
:Rtree [{arg}] If |NERDTree| is installed, open a tree for the
application root or the given subdirectory.
Otherwise, if when the |project| plugin is installed,
invoke :Project (typically without an argument), and
search for the root of the current Rails application.
If it is not found, create a new project, with
appropriate directories (app, etc., but not vendor).
*rails-:Rdbext* *rails-dbext*
:Rdbext [{environment}] This command is only provided when the |dbext| plugin
is installed. Loads the {environment} configuration
(defaults to $RAILS_ENV or development) from
config/database.yml and uses it to configure dbext.
The configuration is cached until a different Rails
application is edited. This command is called for you
automatically when |g:rails_dbext| is set (default on
non-Windows systems).
*rails-:Rdbext!*
:Rdbext! [{environment}]
Load the database configuration as above, and then
attempt a CREATE DATABASE for it. This is primarily
useful for demonstrations.
The configuration is cached on a per application
basis. With dbext versions 8.00 and newer, this
command is called automatically when needed. For
older versions, it is called automatically when
rails.vim loads if |g:rails_dbext| is set (which it is
by default).
*rails-surround*
The |surround| plugin available from vim.org enables adding and removing
@ -722,36 +795,38 @@ core. Supporting plugins and other add-ons to Rails has the potential to
rapidly get out of hand. However, a few pragmatic exceptions have been made.
*rails-template-types*
Commands like :Rview use a hardwired list of extensions (rhtml, rjs, etc.)
Commands like :Rview use a hardwired list of extensions (erb, rjs, etc.)
when searching for files. In order to facilitate working with non-standard
template types, several popular extensions are featured in this list,
including haml, liquid, and mab (markaby). These extensions will disappear
once a related configuration option is added to rails.vim.
*rails-rspec*
Support for RSpec is currently experimental and incomplete, with only a
handful of features being implemented. :A knows about specs and will jump to
them, but only if no test file is found. The associated controller or model
of a spec is detected, so all navigation commands should work as expected
inside a spec file. :Rfixtures will find spec fixtures, but the extension is
mandatory and tab completion will not work. :Rake will run the currently
edited spec.
The presence of a spec directory causes several additional behaviors to
activate. :A knows about specs and will jump to them (but Test::Unit files
still get priority). The associated controller or model of a spec is
detected, so all navigation commands should work as expected inside a spec
file. :Rake in a spec runs just that spec, and in a model, controller, or
helper, runs the associated spec.
While there are currently no built-in dedicated RSpec navigation commands, you
can approximate your own with |:Rcommand|.
|:Runittest| and |:Rfunctionaltest| lead double lives, handling model and
controller specs respectively. For helper and view specs, you can use
|:Rspec| or define your own navigation commands:
>
Rcommand specmodel spec/models -glob=**/*
\ -suffix=_spec.rb -default=model()
Rcommand spechelper spec/helpers -glob=**/*
Rnavcommand spechelper spec/helpers -glob=**/*
\ -suffix=_helper_spec.rb -default=controller()
Rcommand speccontroller spec/controllers -glob=**/*
\ -suffix=_controller_spec.rb -default=controller()
Rcommand specview spec/views -glob=**/* -suffix=_view_spec.rb
Rnavcommand specview spec/views -glob=**/* -suffix=_spec.rb
<
*rails-merb*
Merb support is a long term possibility. For now, if you touch
config/environment.rb in your Merb application, rails.vim will activate.
Send feedback on what's missing to the |rails-plugin-author| and perhaps one
day Merb can be officially supported.
==============================================================================
ABBREVIATIONS *rails-abbreviations* *rails-snippets*
Abbreviations are still experimental. They may later be extracted into a
Abbreviations are "snippets lite". They may later be extracted into a
separate plugin, or removed entirely.
*rails-:Rabbrev*
@ -781,7 +856,7 @@ Rabbrev pa[ params pa.inspect params.inspect
Rabbrev AR:: ActionRecord AR::Base ActiveRecord::Base
Rabbrev :a :action\ =>\ render :a<Tab> render :action =>
In short, :: expands on :, ( expands on (, and [ expands on both . and [.
In short, ( expands on (, :: expands on . and :, and [ expands on . and [.
These trailing punctuation marks are NOT part of the final abbreviation, and
you cannot have two mappings that differ only by punctuation.
@ -790,11 +865,11 @@ an abbreviation ending with "(", you may define where to insert the
parenthesis by splitting the expansion into two parts (divided by an unescaped
space).
Many abbreviations abbreviations are provided by default: use :Rabbrev to list
them. They vary depending on the type of file (models have different
abbreviations than controllers). There is one "smart" abbreviation, :c, which
expands to ":controller => ", ":collection => ", or ":conditions => "
depending on context.
Many abbreviations are provided by default: use :Rabbrev to list them. They
vary depending on the type of file (models have different abbreviations than
controllers). There is one "smart" abbreviation, :c, which expands to
":controller => ", ":collection => ", or ":conditions => " depending on
context.
==============================================================================
SYNTAX HIGHLIGHTING *rails-syntax*
@ -815,7 +890,7 @@ they all link by default to railsMethod.
If you feel a method has been wrongfully omitted, submit it to the
|rails-plugin-author|.
*rails-@params* *rails-syntax-deprecated*
*rails-@params* *rails-syntax-deprecated*
Certain deprecated syntax (like @params and render_text) is highlighted as an
error. If you trigger this highlighting, generally it means you need to
update your code.
@ -843,11 +918,11 @@ syntax group is used. The list of assertions can be refreshed with
*rails-syntax-strings*
In the following line of code, the "?" in the conditions clause and the "ASC"
in the order clause will be highlighted: >
Post.find(:all, :conditions => ["body like ?","%e%"] :order => "title ASC")
Post.find(:all, :conditions => ["body like ?","%e%"], :order => "title ASC")
<
A string literal using %Q<> delimiters will have its contents highlighted as
HTML. This is sometimes useful when writing helpers. >
link = %Q<<a href="http://www.vim.org">Vim</a>>
A string literal using %Q<> or %<> delimiters will have its contents
highlighted as HTML. This is sometimes useful when writing helpers. >
link = %<<a href="http://www.vim.org">Vim</a>>
<
*rails-syntax-yaml*
YAML syntax highlighting has been extended to highlight eRuby, which can be
@ -871,7 +946,7 @@ This makes it easy to access a buried file: >
:find blog_controller.rb
<
*rails-'suffixesadd'* *rails-'sua'*
This is filetype dependent, but typically includes .rb, .rhtml, and several
This is filetype dependent, but typically includes .rb, .rake, and several
others. This allows shortening the above example: >
:find blog_controller
<
@ -882,11 +957,6 @@ The 'includeexpr' option is set to enable the magic described in |rails-gf|.
Useful information is added to the 'statusline', when |g:rails_statusline| is
enabled.
*rails-'makeprg'* *rails-'mp'*
*rails-'errorformat'* *rails-'efm'*
Rake is used as the 'makeprg', so |:make| will work as expected. Also,
'errorformat' is set appropriately to handle your tests.
*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
@ -909,15 +979,16 @@ loaded, you can use an autocommand like the following in your vimrc: >
autocmd User Rails silent! Rlcd
autocmd User Rails map <buffer> <F9> :Rake<CR>
You can also have autocommands that only apply to certain types of files.
These are based off the information shown in the 'statusline' (see
|rails-'statusline'|), with hyphens changed to periods. A few examples: >
These are based off the information shown when running the |:Rails!|
command, with hyphens changed to periods. A few examples: >
autocmd User Rails.controller* iabbr <buffer> wsn wsdl_service_name
autocmd User Rails.model.arb* iabbr <buffer> vfo validates_format_of
autocmd User Rails.view.rhtml* imap <buffer> <C-Z> <%= %><C-O>3h
autocmd User Rails.view.erb* imap <buffer> <C-Z> <%= %><C-O>3h
End all such Rails autocommands with asterisks, even if you have an exact
specification. There is also a filename matching syntax: >
autocmd User Rails/db/schema.rb Rset task=db:schema:dump
autocmd User Rails/**/foo_bar.rb Rabbrev FB:: FooBar
specification, to allow for more specific subtypes to be added in the future.
There is also a filename matching syntax: >
autocmd User Rails/config/environment.rb Rabbrev c config
autocmd User Rails/**/foo_bar.rb Rabbrev FB:: FooBar
Use the filetype based syntax whenever possible, reserving the filename based
syntax for more advanced cases.
@ -930,8 +1001,7 @@ Rails file is loaded.
*config/rails.vim*
If you have settings particular to a specific project, they can be put in a
config/rails.vim file in the root directory of the application. The file is
sourced in the |sandbox| for security reasons. This only works in Vim 7 or
newer.
sourced in the |sandbox| for security reasons.
*rails-:Rset*
:Rset {option}[={value}]
@ -939,9 +1009,9 @@ newer.
called directly, from an autocommand, or from
config/rails.vim.
Options may be set set in one of four scopes, which my be indicated by an
Options may be set in one of four scopes, which may be indicated by an
optional prefix. These scopes determine how broadly an option will apply.
Generally, the default scope is sufficient
Generally, the default scope is sufficient.
Scope Description ~
a: All files in one Rails application
@ -958,15 +1028,12 @@ Option Meaning ~
b:alternate Custom alternate file for :A, relative to the Rails root
b:controller Default controller for certain commands (e.g., :Rhelper)
b:model Default model for certain commands (e.g., :Rfixtures)
l:preview URL stub for :Rpreview (e.g., blog/show/1)
b:task Default task used with :Rake
l:related Custom related file for :R, relative to the Rails root
a:root_url Root URL for commands like :Rpreview
a:ruby_fork_port Experimental: use ruby_fork on given port to speed things up
Examples: >
:Rset root_url=http://localhost:12345
:Rset related=app/views/blog/edit.rhtml preview=blog/edit/1
:Rset related=app/views/blog/edit.html.erb preview=blog/edit/1
:Rset alternate=app/models/
:Rset l:task=preview " Special pseudo-task for :Rake
@ -977,12 +1044,14 @@ If |g:rails_modelines| is enabled, these options can also be set from
modelines near the beginning or end of the file. These modelines will always
set buffer-local options; scope should never be specified. Examples: >
# Rset task=db:schema:load
<%# Rset alternate=app/views/layouts/application.rhtml %>
<%# Rset alternate=app/views/layouts/application.html.erb %>
Modelines can also be local to a method. Example: >
def test_comment
# rset alternate=app/models/comment.rb
These two forms differ only in case.
Modelines are deprecated.
==============================================================================
GLOBAL SETTINGS *rails-global-settings*
@ -991,8 +1060,9 @@ can be enabled by setting them to 1 in your vimrc, and disabled by setting
them to 0. >
let g:rails_some_option=1
let g:rails_some_option=0
Most of these should never need to be used. The few that might be interesting
are |g:rails_expensive|, |g:rails_subversion|, and |g:rails_default_database|.
Most of these seldom need to be used. So seldom, in fact, that you should
notify the |rails-plugin-author| if you find any of them useful, as nearly all
are being considered for removal.
*g:loaded_rails* >
let g:loaded_rails=1
@ -1010,8 +1080,13 @@ like table name completion and commands like >
:Create database brablog_development
:Select * from posts where title like '%Denmark%'
Note that dbext is a complicated plugin, and may require additional
configuration. See |dbext| (if installed) and |sql-completion-dynamic| (in
Vim 7).
configuration. See |dbext| (if installed) and |sql-completion-dynamic|.
*g:rails_ctags_arguments* >
let g:rails_ctags_arguments='--exclude="*.js"'
Additional arguments to pass to ctags from |:Rtags|. Defaults to
'--exclude=facebox.js --exclude="*.*.js"', which attempts to ignore jQuery
plugins that can choke up ctags.
*g:rails_default_file* >
let g:rails_default_file='config/database.yml'
@ -1054,8 +1129,7 @@ Modelines set buffer-local options using the :Rset command.
Also enables method specific modelines (note the case difference): >
def show
# rset preview=blog/show/1
Modelines are extremely useful but may cause security concerns when editing
projects from an untrusted source. Enabled by default.
Modelines are deprecated and disabled by default.
*g:rails_menu* >
let g:rails_menu=1
@ -1070,14 +1144,10 @@ 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.
*g:rails_subversion* >
let g:rails_subversion=1
Automatically add/remove files to the subversion repository for commands like
|:Rgenerate| and |:Rdestroy| (but not |:Rscript|). Ignored when the
application is not part of a subversion repository. Deprecated and disabled
by default.
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
@ -1105,11 +1175,11 @@ 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
In Vim 7, you can keep up to date with |GetLatestVimScripts|.
You can keep up to date with |GetLatestVimScripts|.
The very latest development versions can be retrieved from Git:
http://git.tpope.net/?p=vim-rails.git
git clone git://git.tpope.net/git/vim-rails.git
http://github.com/tpope/vim-rails
git clone git://github.com/tpope/vim-rails.git
Feedback is highly desired on this plugin. Please send all comments,
complaints, and compliments to the author. No bug is too small to report.

View file

@ -37,7 +37,7 @@ function! s:error(str)
endfunction
function! s:autoload(...)
if !exists("g:autoloaded_rails")
if !exists("g:autoloaded_rails") && v:version >= 700
runtime! autoload/rails.vim
endif
if exists("g:autoloaded_rails")
@ -48,7 +48,11 @@ function! s:autoload(...)
endif
if !exists("g:rails_no_autoload_warning")
let g:rails_no_autoload_warning = 1
call s:error("Disabling rails.vim: autoload/rails.vim is missing")
if v:version >= 700
call s:error("Disabling rails.vim: autoload/rails.vim is missing")
else
call s:error("Disabling rails.vim: Vim version 7 or higher required")
endif
endif
return ""
endfunction
@ -62,24 +66,21 @@ function! s:SetOptDefault(opt,val)
endif
endfunction
call s:SetOptDefault("rails_level",3)
call s:SetOptDefault("rails_statusline",1)
call s:SetOptDefault("rails_syntax",1)
call s:SetOptDefault("rails_mappings",1)
call s:SetOptDefault("rails_abbreviations",1)
call s:SetOptDefault("rails_expensive",1+0*(has("win32")||has("win32unix")))
call s:SetOptDefault("rails_ctags_arguments","--exclude=\"*.js\"")
call s:SetOptDefault("rails_expensive",1)
call s:SetOptDefault("rails_dbext",g:rails_expensive)
call s:SetOptDefault("rails_subversion",0)
call s:SetOptDefault("rails_default_file","README")
call s:SetOptDefault("rails_default_database","")
call s:SetOptDefault("rails_root_url",'http://localhost:3000/')
call s:SetOptDefault("rails_modelines",1)
call s:SetOptDefault("rails_modelines",0)
call s:SetOptDefault("rails_menu",1)
call s:SetOptDefault("rails_gnu_screen",1)
call s:SetOptDefault("rails_history_size",5)
call s:SetOptDefault("rails_debug",0)
call s:SetOptDefault("rails_generators","controller\nintegration_test\nmailer\nmigration\nmodel\nobserver\nplugin\nresource\nscaffold\nsession_migration")
call s:SetOptDefault("rails_rake_tasks","db:charset\ndb:collation\ndb:create\ndb:create:all\ndb:drop\ndb:drop:all\ndb:fixtures:identify\ndb:fixtures:load\ndb:migrate\ndb:reset\ndb:rollback\ndb:schema:dump\ndb:schema:load\ndb:sessions:clear\ndb:sessions:create\ndb:structure:dump\ndb:test:clone\ndb:test:clone_structure\ndb:test:prepare\ndb:test:purge\ndb:version\ndoc:app\ndoc:clobber_app\ndoc:clobber_plugins\ndoc:clobber_rails\ndoc:plugins\ndoc:rails\ndoc:reapp\ndoc:rerails\nlog:clear\nnotes\nnotes:fixme\nnotes:optimize\nnotes:todo\nrails:freeze:edge\nrails:freeze:gems\nrails:unfreeze\nrails:update\nrails:update:configs\nrails:update:javascripts\nrails:update:scripts\nroutes\nstats\ntest\ntest:functionals\ntest:integration\ntest:plugins\ntest:recent\ntest:uncommitted\ntest:units\ntmp:cache:clear\ntmp:clear\ntmp:create\ntmp:pids:clear\ntmp:sessions:clear\ntmp:sockets:clear")
if g:rails_dbext
if exists("g:loaded_dbext") && executable("sqlite3") && ! executable("sqlite")
" Since dbext can't find it by itself
@ -99,11 +100,15 @@ endfunction
function! s:Detect(filename)
let fn = substitute(fnamemodify(a:filename,":p"),'\c^file://','','')
let sep = matchstr(fn,'^[^\\/]\{3,\}\zs[\\/]')
if sep != ""
let fn = getcwd().sep.fn
endif
if fn =~ '[\/]config[\/]environment\.rb$'
return s:BufInit(strpart(fn,0,strlen(fn)-22))
endif
if isdirectory(fn)
let fn = fnamemodify(fn,":s?[\/]$??")
let fn = fnamemodify(fn,':s?[\/]$??')
else
let fn = fnamemodify(fn,':s?\(.*\)[\/][^\/]*$?\1?')
endif
@ -122,7 +127,7 @@ function! s:Detect(filename)
return s:BufInit(fn)
endif
let ofn = fn
let fn = fnamemodify(ofn,':s?\(.*\)[\/]\(app\|config\|db\|doc\|lib\|log\|public\|script\|spec\|test\|tmp\|vendor\)\($\|[\/].*$\)?\1?')
let fn = fnamemodify(ofn,':s?\(.*\)[\/]\(app\|config\|db\|doc\|features\|lib\|log\|public\|script\|spec\|stories\|test\|tmp\|vendor\)\($\|[\/].*$\)?\1?')
endwhile
return 0
endfunction
@ -144,10 +149,10 @@ augroup railsPluginDetect
autocmd FileType netrw if !exists("b:rails_root") | call s:Detect(expand("<afile>:p")) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif
autocmd BufEnter * if exists("b:rails_root")|silent doau User BufEnterRails|endif
autocmd BufLeave * if exists("b:rails_root")|silent doau User BufLeaveRails|endif
autocmd FileType railslog if s:autoload()|call RailslogSyntax()|endif
autocmd Syntax railslog if s:autoload()|call rails#log_syntax()|endif
augroup END
command! -bar -bang -nargs=* -complete=dir Rails :if s:autoload()|call RailsNewApp(<bang>0,<f-args>)|endif
command! -bar -bang -nargs=* -complete=dir Rails :if s:autoload()|call rails#new_app_command(<bang>0,<f-args>)|endif
" }}}1
" Menus {{{1
@ -164,6 +169,10 @@ function! s:gsub(str,pat,rep)
return substitute(a:str,'\v\C'.a:pat,a:rep,'g')
endfunction
function! s:menucmd(priority)
return 'anoremenu <script> '.(exists("$CREAM") ? 87 : '').s:gsub(g:rails_installed_menu,'[^.]','').'.'.a:priority.' '
endfunction
function! s:CreateMenus() abort
if exists("g:rails_installed_menu") && g:rails_installed_menu != ""
exe "aunmenu ".s:gsub(g:rails_installed_menu,'\&','')
@ -175,14 +184,14 @@ function! s:CreateMenus() abort
else
let g:rails_installed_menu = '&Plugin.&Rails'
endif
let dots = s:gsub(g:rails_installed_menu,'[^.]','')
let menucmd = s:menucmd(200)
if exists("$CREAM")
let menucmd = '87anoremenu <script> '
exe menucmd.g:rails_installed_menu.'.-PSep- :'
exe menucmd.g:rails_installed_menu.'.&Related\ file\ :R\ /\ Alt+] :R<CR>'
exe menucmd.g:rails_installed_menu.'.&Alternate\ file\ :A\ /\ Alt+[ :A<CR>'
exe menucmd.g:rails_installed_menu.'.&File\ under\ cursor\ Ctrl+Enter :Rfind<CR>'
else
let menucmd = 'anoremenu <script> '
exe menucmd.g:rails_installed_menu.'.-PSep- :'
exe menucmd.g:rails_installed_menu.'.&Related\ file\ :R\ /\ ]f :R<CR>'
exe menucmd.g:rails_installed_menu.'.&Alternate\ file\ :A\ /\ [f :A<CR>'
@ -195,36 +204,24 @@ function! s:CreateMenus() abort
exe menucmd.g:rails_installed_menu.'.&Other\ files.Application\ &README :find doc/README_FOR_APP<CR>'
exe menucmd.g:rails_installed_menu.'.&Other\ files.&Environment :find config/environment.rb<CR>'
exe menucmd.g:rails_installed_menu.'.&Other\ files.&Database\ Configuration :find config/database.yml<CR>'
exe menucmd.g:rails_installed_menu.'.&Other\ files.Database\ &Schema :call <SID>findschema()<CR>'
exe menucmd.g:rails_installed_menu.'.&Other\ files.Database\ &Schema :Rmigration 0<CR>'
exe menucmd.g:rails_installed_menu.'.&Other\ files.R&outes :find config/routes.rb<CR>'
exe menucmd.g:rails_installed_menu.'.&Other\ files.&Test\ Helper :find test/test_helper.rb<CR>'
exe menucmd.g:rails_installed_menu.'.-FSep- :'
exe menucmd.g:rails_installed_menu.'.Ra&ke\ :Rake :Rake<CR>'
let tasks = g:rails_rake_tasks
while tasks != ''
let task = matchstr(tasks,'.\{-\}\ze\%(\n\|$\)')
let tasks = s:sub(tasks,'.{-}%(\n|$)','')
exe menucmd.g:rails_installed_menu.'.Rake\ &tasks\ :Rake.'.s:sub(s:sub(task,'^[^:]*$','&:all'),':','.').' :Rake '.task.'<CR>'
endwhile
let tasks = g:rails_generators
while tasks != ''
let task = matchstr(tasks,'.\{-\}\ze\%(\n\|$\)')
let tasks = s:sub(tasks,'.{-}%(\n|$)','')
exe menucmd.'<silent> '.g:rails_installed_menu.'.&Generate\ :Rgen.'.s:gsub(task,'_','\\ ').' :call <SID>menuprompt("Rgenerate '.task.'","Arguments for script/generate '.task.': ")<CR>'
exe menucmd.'<silent> '.g:rails_installed_menu.'.&Destroy\ :Rdestroy.'.s:gsub(task,'_','\\ ').' :call <SID>menuprompt("Rdestroy '.task.'","Arguments for script/destroy '.task.': ")<CR>'
endwhile
let menucmd = substitute(menucmd,'200 $','500 ','')
exe menucmd.g:rails_installed_menu.'.&Server\ :Rserver.&Start\ :Rserver :Rserver<CR>'
exe menucmd.g:rails_installed_menu.'.&Server\ :Rserver.&Force\ start\ :Rserver! :Rserver!<CR>'
exe menucmd.g:rails_installed_menu.'.&Server\ :Rserver.&Kill\ :Rserver!\ - :Rserver! -<CR>'
exe menucmd.'<silent> '.g:rails_installed_menu.'.&Evaluate\ Ruby\.\.\.\ :Rp :call <SID>menuprompt("Rp","Code to execute and output: ")<CR>'
exe menucmd.g:rails_installed_menu.'.&Console\ :Rconsole :Rconsole<CR>'
exe substitute(menucmd,'<script>','<script> <silent>','').g:rails_installed_menu.'.&Evaluate\ Ruby\.\.\.\ :Rp :call <SID>menuprompt("Rp","Code to execute and output: ")<CR>'
exe menucmd.g:rails_installed_menu.'.&Console\ :Rscript :Rscript console<CR>'
exe menucmd.g:rails_installed_menu.'.&Preview\ :Rpreview :Rpreview<CR>'
exe menucmd.g:rails_installed_menu.'.&Log\ file\ :Rlog :Rlog<CR>'
exe s:sub(menucmd,'anoremenu','vnoremenu').' <silent> '.g:rails_installed_menu.'.E&xtract\ as\ partial\ :Rextract :call <SID>menuprompt("'."'".'<,'."'".'>Rextract","Partial name (e.g., template or /controller/template): ")<CR>'
exe substitute(s:sub(menucmd,'anoremenu','vnoremenu'),'<script>','<script> <silent>','').g:rails_installed_menu.'.E&xtract\ as\ partial\ :Rextract :call <SID>menuprompt("'."'".'<,'."'".'>Rextract","Partial name (e.g., template or /controller/template): ")<CR>'
exe menucmd.g:rails_installed_menu.'.&Migration\ writer\ :Rinvert :Rinvert<CR>'
exe menucmd.' '.g:rails_installed_menu.'.-HSep- :'
exe menucmd.'<silent> '.g:rails_installed_menu.'.&Help\ :help\ rails :if <SID>autoload()<Bar>exe RailsHelpCommand("")<Bar>endif<CR>'
exe menucmd.'<silent> '.g:rails_installed_menu.'.Abo&ut\ :if <SID>autoload()<Bar>exe RailsHelpCommand("about")<Bar>endif<CR>'
exe substitute(menucmd,'<script>','<script> <silent>','').g:rails_installed_menu.'.&Help\ :help\ rails :if <SID>autoload()<Bar>exe RailsHelpCommand("")<Bar>endif<CR>'
exe substitute(menucmd,'<script>','<script> <silent>','').g:rails_installed_menu.'.Abo&ut\ :if <SID>autoload()<Bar>exe RailsHelpCommand("about")<Bar>endif<CR>'
let g:rails_did_menus = 1
call s:ProjectMenu()
call s:menuBufLeave()
@ -264,6 +261,27 @@ function! s:menuBufEnter()
exe 'amenu disable '.menu.'.Migration\ writer'
endif
call s:ProjectMenu()
silent! exe 'aunmenu '.menu.'.Rake\ tasks'
silent! exe 'aunmenu '.menu.'.Generate'
silent! exe 'aunmenu '.menu.'.Destroy'
if rails#app().cache.needs('rake_tasks') || empty(rails#app().rake_tasks())
exe substitute(s:menucmd(300),'<script>','<script> <silent>','').g:rails_installed_menu.'.Rake\ &tasks\ :Rake.Fill\ this\ menu :call rails#app().rake_tasks()<Bar>call <SID>menuBufLeave()<Bar>call <SID>menuBufEnter()<CR>'
else
let i = 0
while i < len(rails#app().rake_tasks())
let task = rails#app().rake_tasks()[i]
exe s:menucmd(300).g:rails_installed_menu.'.Rake\ &tasks\ :Rake.'.s:sub(task,':',':.').' :Rake '.task.'<CR>'
let i += 1
endwhile
endif
let i = 0
let menucmd = substitute(s:menucmd(400),'<script>','<script> <silent>','').g:rails_installed_menu
while i < len(rails#app().generators())
let generator = rails#app().generators()[i]
exe menucmd.'.&Generate\ :Rgen.'.s:gsub(generator,'_','\\ ').' :call <SID>menuprompt("Rgenerate '.generator.'","Arguments for script/generate '.generator.': ")<CR>'
exe menucmd.'.&Destroy\ :Rdestroy.'.s:gsub(generator,'_','\\ ').' :call <SID>menuprompt("Rdestroy '.generator.'","Arguments for script/destroy '.generator.': ")<CR>'
let i += 1
endwhile
endif
endfunction
@ -274,6 +292,12 @@ function! s:menuBufLeave()
exe 'amenu enable '.menu.'.Help\ '
exe 'amenu enable '.menu.'.About\ '
exe 'amenu enable '.menu.'.Projects'
silent! exe 'aunmenu '.menu.'.Rake\ tasks'
silent! exe 'aunmenu '.menu.'.Generate'
silent! exe 'aunmenu '.menu.'.Destroy'
exe s:menucmd(300).g:rails_installed_menu.'.Rake\ tasks\ :Rake.-TSep- :'
exe s:menucmd(400).g:rails_installed_menu.'.&Generate\ :Rgen.-GSep- :'
exe s:menucmd(400).g:rails_installed_menu.'.&Destroy\ :Rdestroy.-DSep- :'
endif
endfunction
@ -285,17 +309,6 @@ function! s:menuprompt(vimcmd,prompt)
exe a:vimcmd." ".res
endfunction
function! s:findschema()
let env = exists('$RAILS_ENV') ? $RAILS_ENV : "development"
if filereadable(b:rails_root."/db/schema.rb")
edit `=b:rails_root.'/db/schema.rb'`
elseif filereadable(b:rails_root.'/db/'.env.'_structure.sql')
edit `=b:rails_root.'/db/'.env.'_structure.sql'`
else
return s:error("Schema not found: try :Rake db:schema:dump")
endif
endfunction
call s:CreateMenus()
augroup railsPluginMenu