Skip to content

Commit 60ff461

Browse files
committed
Remove abbreviations
1 parent ec9b2b0 commit 60ff461

File tree

3 files changed

+3
-233
lines changed

3 files changed

+3
-233
lines changed

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ applications.
3838

3939
* Fully customizable. Define "projections" at the global, app, or gem
4040
level to define navigation commands and override the alternate file,
41-
default rake task, syntax highlighting, abbreviations, and more.
41+
default rake task, syntax highlighting, and more.
4242
`:help rails-projections`.
4343

4444
* Integration with other plugins. If [dispatch.vim][] is installed, `:Rails`

autoload/rails.vim

Lines changed: 1 addition & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ call s:add_methods('app', ['has_zeus', 'ruby_script_command','static_rails_comma
10761076
function! s:BufCommands()
10771077
call s:BufNavCommands()
10781078
call s:BufScriptWrappers()
1079-
command! -buffer -bar -nargs=* -bang Rabbrev :call s:Abbrev(<bang>0,<f-args>)
1079+
command! -buffer -bar -nargs=* -bang Rabbrev :echoerr "Rabbrev has been removed."
10801080
command! -buffer -bar -nargs=? -bang -count -complete=customlist,rails#complete_rake Rake :call s:Rake(<bang>0,!<count> && <line1> ? -1 : <count>,<q-args>)
10811081
command! -buffer -bar -nargs=? -bang -range -complete=customlist,s:Complete_preview Rbrowse :call s:Preview(<bang>0,<line1>,<q-args>)
10821082
command! -buffer -bar -nargs=? -bang -range -complete=customlist,s:Complete_preview Preview :call s:Preview(<bang>0,<line1>,<q-args>)
@@ -4263,186 +4263,6 @@ function! rails#db_complete_fragment(url, ...) abort
42634263
return len(app) ? app.environments() : []
42644264
endfunction
42654265

4266-
" }}}1
4267-
" Abbreviations {{{1
4268-
4269-
function! s:selectiveexpand(pat,good,default,...)
4270-
if a:0 > 0
4271-
let nd = a:1
4272-
else
4273-
let nd = ""
4274-
endif
4275-
let c = nr2char(getchar(0))
4276-
let good = a:good
4277-
if c == "" " ^]
4278-
return s:sub(good.(a:0 ? " ".a:1 : ''),'\s+$','')
4279-
elseif c == "\t"
4280-
return good.(a:0 ? " ".a:1 : '')
4281-
elseif c =~ a:pat
4282-
return good.c.(a:0 ? a:1 : '')
4283-
else
4284-
return a:default.c
4285-
endif
4286-
endfunction
4287-
4288-
function! s:AddSelectiveExpand(abbr,pat,expn,...)
4289-
let expn = s:gsub(s:gsub(a:expn ,'[\"|]','\\&'),'\<','\\<Lt>')
4290-
let expn2 = s:gsub(s:gsub(a:0 ? a:1 : '','[\"|]','\\&'),'\<','\\<Lt>')
4291-
if a:0
4292-
exe "inoreabbrev <buffer> <silent> ".a:abbr." <C-R>=<SID>selectiveexpand(".string(a:pat).",\"".expn."\",".string(a:abbr).",\"".expn2."\")<CR>"
4293-
else
4294-
exe "inoreabbrev <buffer> <silent> ".a:abbr." <C-R>=<SID>selectiveexpand(".string(a:pat).",\"".expn."\",".string(a:abbr).")<CR>"
4295-
endif
4296-
endfunction
4297-
4298-
function! s:AddTabExpand(abbr,expn)
4299-
call s:AddSelectiveExpand(a:abbr,'..',a:expn)
4300-
endfunction
4301-
4302-
function! s:AddBracketExpand(abbr,expn)
4303-
call s:AddSelectiveExpand(a:abbr,'[[.]',a:expn)
4304-
endfunction
4305-
4306-
function! s:AddColonExpand(abbr,expn)
4307-
call s:AddSelectiveExpand(a:abbr,'[:.]',a:expn)
4308-
endfunction
4309-
4310-
function! s:AddParenExpand(abbr,expn,...)
4311-
if a:0
4312-
call s:AddSelectiveExpand(a:abbr,'(',a:expn,a:1)
4313-
else
4314-
call s:AddSelectiveExpand(a:abbr,'(',a:expn,'')
4315-
endif
4316-
endfunction
4317-
4318-
function! s:BufAbbreviations()
4319-
" Some of these were cherry picked from the TextMate snippets
4320-
if !exists('g:rails_no_abbreviations')
4321-
let buffer = rails#buffer()
4322-
" Limit to the right filetypes. But error on the liberal side
4323-
if buffer.type_name('controller','view','helper','test-controller','test-helper','test-integration')
4324-
Rabbrev pa[ params
4325-
Rabbrev rq[ request
4326-
Rabbrev rs[ response
4327-
Rabbrev se[ session
4328-
Rabbrev hd[ headers
4329-
Rabbrev coo[ cookies
4330-
Rabbrev fl[ flash
4331-
Rabbrev rr( render
4332-
" ))))))
4333-
endif
4334-
if buffer.type_name('controller')
4335-
Rabbrev re( redirect_to
4336-
Rabbrev rst( respond_to
4337-
" ))
4338-
endif
4339-
if buffer.type_name() ==# 'model' || buffer.type_name('model-record')
4340-
Rabbrev bt( belongs_to
4341-
Rabbrev ho( has_one
4342-
Rabbrev hm( has_many
4343-
Rabbrev habtm( has_and_belongs_to_many
4344-
Rabbrev co( composed_of
4345-
Rabbrev va( validates_associated
4346-
Rabbrev vb( validates_acceptance_of
4347-
Rabbrev vc( validates_confirmation_of
4348-
Rabbrev ve( validates_exclusion_of
4349-
Rabbrev vf( validates_format_of
4350-
Rabbrev vi( validates_inclusion_of
4351-
Rabbrev vl( validates_length_of
4352-
Rabbrev vn( validates_numericality_of
4353-
Rabbrev vp( validates_presence_of
4354-
Rabbrev vu( validates_uniqueness_of
4355-
" )))))))))))))))
4356-
endif
4357-
if buffer.type_name('db-migration','db-schema')
4358-
Rabbrev mac( add_column
4359-
Rabbrev mrnc( rename_column
4360-
Rabbrev mrc( remove_column
4361-
Rabbrev mct( create_table
4362-
Rabbrev mcht( change_table
4363-
Rabbrev mrnt( rename_table
4364-
Rabbrev mdt( drop_table
4365-
" )))))))
4366-
endif
4367-
Rabbrev logd( logger.debug
4368-
Rabbrev logi( logger.info
4369-
Rabbrev logw( logger.warn
4370-
Rabbrev loge( logger.error
4371-
Rabbrev logf( logger.fatal
4372-
Rabbrev AR:: ActiveRecord
4373-
Rabbrev AV:: ActionView
4374-
Rabbrev AC:: ActionController
4375-
Rabbrev AD:: ActionDispatch
4376-
Rabbrev AS:: ActiveSupport
4377-
Rabbrev AM:: ActionMailer
4378-
Rabbrev AO:: ActiveModel
4379-
Rabbrev AJ:: ActiveJob
4380-
" )))))
4381-
for pairs in
4382-
\ items(get(g:, 'rails_abbreviations', {}))
4383-
call call(function(s:sid.'Abbrev'), [0, pairs[0]] + s:split(pairs[1]))
4384-
endfor
4385-
for hash in reverse(rails#buffer().projected('abbreviations'))
4386-
for pairs in items(hash)
4387-
call call(function(s:sid.'Abbrev'), [0, pairs[0]] + s:split(pairs[1]))
4388-
endfor
4389-
endfor
4390-
endif
4391-
endfunction
4392-
4393-
function! s:Abbrev(bang,...) abort
4394-
if !exists("b:rails_abbreviations")
4395-
let b:rails_abbreviations = {}
4396-
endif
4397-
if a:0 > 3 || (a:bang && (a:0 != 1))
4398-
return s:error("Rabbrev: invalid arguments")
4399-
endif
4400-
if a:0 == 0
4401-
for key in sort(keys(b:rails_abbreviations))
4402-
echo key . join(b:rails_abbreviations[key],"\t")
4403-
endfor
4404-
return
4405-
endif
4406-
let lhs = a:1
4407-
let root = s:sub(lhs,'%(::|\(|\[)$','')
4408-
if a:bang
4409-
if has_key(b:rails_abbreviations,root)
4410-
call remove(b:rails_abbreviations,root)
4411-
endif
4412-
exe "iunabbrev <buffer> ".root
4413-
return
4414-
endif
4415-
if a:0 > 3 || a:0 < 2
4416-
return s:error("Rabbrev: invalid arguments")
4417-
endif
4418-
let rhs = a:2
4419-
if has_key(b:rails_abbreviations,root)
4420-
call remove(b:rails_abbreviations,root)
4421-
endif
4422-
if lhs =~ '($'
4423-
let b:rails_abbreviations[root] = ["(", rhs . (a:0 > 2 ? "\t".a:3 : "")]
4424-
if a:0 > 2
4425-
call s:AddParenExpand(root,rhs,a:3)
4426-
else
4427-
call s:AddParenExpand(root,rhs)
4428-
endif
4429-
return
4430-
endif
4431-
if a:0 > 2
4432-
return s:error("Rabbrev: invalid arguments")
4433-
endif
4434-
if lhs =~ ':$'
4435-
call s:AddColonExpand(root,rhs)
4436-
elseif lhs =~ '\[$'
4437-
call s:AddBracketExpand(root,rhs)
4438-
elseif lhs =~ '\w$'
4439-
call s:AddTabExpand(lhs,rhs)
4440-
else
4441-
return s:error("Rabbrev: unimplemented")
4442-
endif
4443-
let b:rails_abbreviations[root] = [matchstr(lhs,'\W*$'),rhs]
4444-
endfunction
4445-
44464266
" }}}1
44474267
" Projections {{{1
44484268

@@ -5147,7 +4967,6 @@ function! rails#buffer_setup() abort
51474967
call s:BufMappings()
51484968
call s:BufCommands()
51494969
call s:BufProjectionCommands()
5150-
call s:BufAbbreviations()
51514970

51524971
if ft =~# '^ruby\>'
51534972
call self.setvar('&define',self.define_pattern())

doc/rails.txt

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Author: Tim Pope <http://tpo.pe/>
1515
|rails-integration| Integration
1616
|rails-vim-integration| Integration with the Vim Universe
1717
|rails-rails-integration| Integration with the Rails Universe
18-
|rails-abbreviations| Abbreviations
1918
|rails-syntax| Syntax Highlighting
2019
|rails-projections| Projections
2120
|rails-configuration| Configuration
@@ -585,55 +584,7 @@ controller/mailer specs respectively. For everything else, you can use
585584

586585
ABBREVIATIONS *rails-abbreviations* *rails-snippets*
587586

588-
Abbreviations are "snippets lite". They may later be extracted into a
589-
separate plugin, or removed entirely.
590-
591-
*rails-:Rabbrev*
592-
:Rabbrev List all Rails abbreviations.
593-
594-
:Rabbrev {abbr} {expn} [{extra}]
595-
Define a new Rails abbreviation. {extra} is permitted
596-
if and only if {expn} ends with "(".
597-
598-
*rails-:Rabbrev!*
599-
:Rabbrev! {abbr} Remove an abbreviation.
600-
601-
Rails abbreviations differ from regular abbreviations in that they only expand
602-
after a <C-]> (see |i_CTRL-]|) or a <Tab> (if <Tab> does not work, it is
603-
likely mapped by another plugin). If the abbreviation ends in certain
604-
punctuation marks, additional expansions are possible. A few examples will
605-
hopefully clear this up (all of the following are enabled by default in
606-
appropriate file types).
607-
608-
Command Sequence typed Resulting text ~
609-
Rabbrev rp( render :partial\ => rp( render(:partial =>
610-
Rabbrev rp( render :partial\ => rp<Tab> render :partial =>
611-
Rabbrev vs( validates_size_of vs( validates_size_of(
612-
Rabbrev pa[ params pa[:id] params[:id]
613-
Rabbrev pa[ params pa<C-]> params
614-
Rabbrev pa[ params pa.inspect params.inspect
615-
Rabbrev AR:: ActionRecord AR::Base ActiveRecord::Base
616-
617-
In short, ( expands on (, :: expands on . and :, and [ expands on . and [.
618-
These trailing punctuation marks are NOT part of the final abbreviation, and
619-
you cannot have two mappings that differ only by punctuation.
620-
621-
You must escape spaces in your expansion, either as "\ " or as "<Space>". For
622-
an abbreviation ending with "(", you may define where to insert the
623-
parenthesis by splitting the expansion into two parts (divided by an unescaped
624-
space).
625-
626-
You can also define abbreviations as a hash in |g:rails_abbreviations| or by
627-
using |rails-projection-abbreviations|:
628-
>
629-
let g:rails_abbreviations = {
630-
\ "AE::": "ActiveResource",
631-
\ "p[": "params",
632-
\ "rj(": ["render", "json: "]}
633-
<
634-
Many abbreviations are provided by default: use :Rabbrev to list them. They
635-
vary depending on the type of file (models have different abbreviations than
636-
controllers).
587+
Abbreviations have been removed without replacement.
637588

638589
SYNTAX HIGHLIGHTING *rails-syntax*
639590

0 commit comments

Comments
 (0)