Skip to content

Commit 379a36e

Browse files
committed
Show file type information in :Rails! output
1 parent 5a5c93d commit 379a36e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

autoload/rails.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,13 @@ endfunction
817817

818818
function! rails#new_app_command(bang,...)
819819
if a:0 == 0
820-
if a:bang
821-
echo "rails.vim version ".g:autoloaded_rails
820+
let msg = "rails.vim ".g:autoloaded_rails
821+
if a:bang && exists('b:rails_root') && RailsFileType() == ''
822+
echo msg." (Rails)"
823+
elseif a:bang && exists('b:rails_root')
824+
echo msg." (Rails-".RailsFileType().")"
825+
elseif a:bang
826+
echo msg
822827
else
823828
!rails
824829
endif

doc/rails.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ actually edit a file from a Rails application.
129129
:Rails {directory} The only global command. Creates a new Rails
130130
application in {directory}, and loads the README.
131131

132+
:Rails! Show the version of rails.vim installed. If rails.vim
133+
is active for the current buffer, also show the type
134+
of Rails file detected.
135+
132136
*rails-:Rake*
133137
:[range]Rake {targets} Like calling |:make| {targets} (with 'makeprg' being
134138
rake). However, in some contexts, if {targets} are
@@ -926,13 +930,14 @@ loaded, you can use an autocommand like the following in your vimrc: >
926930
autocmd User Rails silent! Rlcd
927931
autocmd User Rails map <buffer> <F9> :Rake<CR>
928932
You can also have autocommands that only apply to certain types of files.
929-
These are based off the information shown in the 'statusline' (see
930-
|rails-'statusline'|), with hyphens changed to periods. A few examples: >
933+
These are based off the information shown when running the |:Rails!|
934+
command, with hyphens changed to periods. A few examples: >
931935
autocmd User Rails.controller* iabbr <buffer> wsn wsdl_service_name
932936
autocmd User Rails.model.arb* iabbr <buffer> vfo validates_format_of
933937
autocmd User Rails.view.erb* imap <buffer> <C-Z> <%= %><C-O>3h
934938
End all such Rails autocommands with asterisks, even if you have an exact
935-
specification. There is also a filename matching syntax: >
939+
specification, to allow for more specific subtypes to be added in the future.
940+
There is also a filename matching syntax: >
936941
autocmd User Rails/db/schema.rb Rset task=db:schema:dump
937942
autocmd User Rails/**/foo_bar.rb Rabbrev FB:: FooBar
938943
Use the filetype based syntax whenever possible, reserving the filename based

0 commit comments

Comments
 (0)