Skip to content

Commit

Permalink
Added vim config
Browse files Browse the repository at this point in the history
  • Loading branch information
jstorimer committed Jun 3, 2010
1 parent f2ea1ab commit 95822b0
Show file tree
Hide file tree
Showing 45 changed files with 16,174 additions and 24 deletions.
1 change: 1 addition & 0 deletions vim/.VimballRecord
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
snippy_plugin.vba: call delete('/Users/jferris/.vim/plugin/snippetsEmu.vim')|call delete('/Users/jferris/.vim/doc/snippets_emu.txt')
16 changes: 16 additions & 0 deletions vim/after/ftplugin/cucumber.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
" Webrat steps
Snippet press When I press "<{}>"
Snippet follow When I follow "<{}>"
Snippet fillin When I fill in "<{}>"
Snippet select When I select "<{}>"
Snippet check When I check "<{}>"
Snippet uncheck When I uncheck "<{}>"
Snippet choose When I choose "<{}>"
Snippet see Then I should see "<{}>"
Snippet notsee Then I should not see "<{}>"
Snippet visit When I visit <{}>

" Factory steps
Snippet exist Given a <{factory}> exists with a <{attribute}> of "<{}>"

vmap <buffer> <C-A> !align_ascii_table<CR>
28 changes: 28 additions & 0 deletions vim/after/ftplugin/eruby.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function! ERubyIterVar()
let line = getline('.')
let col = col('.')
let collection = line[0 : col]
" remove .each or .collect
let collection = substitute(collection,"\\.[^.]*$","","")
" remove eruby escapes
let collection = substitute(collection,"^<%","","")
" remove leading space
let collection = substitute(collection,"^\\s\\+","","")
" remove chains like post.users
let collection = substitute(collection,"^.*\\.","","")
" remove instance variable punctuatoin
let collection = substitute(collection,"^@","","")
" singularize
return rails#singularize(collection)
endfunction

" general ruby snippets
Snippet each each do |``ERubyIterVar()``| -%><CR><{}><CR><% end -%>
Snippet map map do |``ERubyIterVar()``|<CR><{}><CR>end
" Snippet each <% <{collection}>.each do |<{member}>| -%><CR><{}><CR><% end %>
Snippet h <%=h <{}> %>
Snippet = <%= <{}> %>
Snippet rendp <%= render :partial => '<{}>' %>
Snippet rendc <%= render :partial => @<{}> %>
Snippet rendo <%= render :partial => @<{}> %>
Snippet lt <%= link_to '<{caption}>', <{}> %>
167 changes: 167 additions & 0 deletions vim/after/ftplugin/ruby.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
" functions
function! SpecDescribed()
let curline = line(".")
let curcol = col(".")
let line = search("describe", "bW")
if line > 0
let line = getline(line)
let subject = substitute(matchstr(line, "describe [^, ]*"), "^describe ", "", "")
call cursor(curline, curcol)
return subject
else
return 'subject'
endif
endfunction

function! SpecSubject()
return rails#underscore(SpecDescribed())
endfunction

function! InSpecBlock()
let curcol = col(".")
if curcol > 1
return 1
else
return 0
endif
endfunction

function! DefaultSpecDescribe()
if InSpecBlock()
return "describe"
else
return "describe Object,"
endif
endfunction

function! IterVar()
let line = getline('.')
let col = col('.')
let collection = line[0 : col]
" remove .each or .collect
let collection = substitute(collection,"\\.[^.]*$","","")
" remove leading space
let collection = substitute(collection,"^\\s\\+","","")
" remove chains like post.users
let collection = substitute(collection,"^.*\\.","","")
" remove instance variable punctuatoin
let collection = substitute(collection,"^@","","")
" singularize
return rails#singularize(collection)
endfunction

" general ruby snippets
Snippet each each do |``IterVar()``|<CR><{}><CR>end
Snippet map map do |``IterVar()``|<CR><{}><CR>end
Snippet eachl each { |``IterVar()``| <{}> }
Snippet mapl map { |``IterVar()``| <{}> }
" active record associations
Snippet bt belongs_to :<{}>
Snippet ho has_one :<{}>
Snippet hm has_many :<{}>
Snippet habtm has_and_belongs_to_many :<{}>
Snippet hmt has_many :<{association}>, :through => <{}>

" active record validations
Snippet vpo validates_presence_of :<{attribute}><{}>
Snippet vpos validates_presence_of :<{attribute}>, :scope => <{scope}><CR><{}>

" shoulda validation macros
Snippet shal should_allow_values_for :<{attribute}>, <{}>
Snippet should_ensure_length_at_least should_ensure_length_at_least :<{attribute}>, <{length}><CR><{}>
Snippet should_ensure_length_in_range should_ensure_length_in_range :<{attribute}>, <{range}><CR><{}>
Snippet should_ensure_length_is should_ensure_length_is :<{attribute}>, <{length}><CR><{}>
Snippet should_ensure_value_in_range should_ensure_value_in_range :<{attribute}>, <{range}><CR><{}>
Snippet shnal should_not_allow_values_for :<{attribute}>, <{}>
Snippet shalnum should_only_allow_numeric_values_for :<{}>
Snippet shprot should_protect_attributes :<{}>
Snippet shreqacc should_require_acceptance_of :<{}>
Snippet shreq should_require_attributes :<{}>
Snippet shrequniq should_require_unique_attributes :<{}>

" Factory girl
Snippet F Factory(:<{factory}>)<{}>
Snippet Fb Factory.build(:<{factory}>)<{}>
Snippet Fw Factory(:<{factory}>, :<{}>)
Snippet Fbw Factory.build(:<{factory}>, :<{}>)

" shoulda association macros
Snippet shbt should_belong_to :<{association}><CR><{}>
Snippet shhabtm should_have_and_belong_to_many :<{association}><CR><{}>
Snippet shhm should_have_many :<{association}><CR><{}>
Snippet shho should_have_one :<{association}><CR><{}>

" shoulda controller macros
Snippet shass should_assign_to :<{}>
Snippet shnass should_not_assign_to :<{}>
Snippet shnfl should_not_set_the_flash<{}>
Snippet shred should_redirect_to "<{}>"
Snippet shrend should_render_template :<{}>
Snippet shlay should_render_without_layout :<{}>
Snippet shres should_respond_with :<{}>
Snippet shroute should_route :<{method}>, "<{path}>", :action => :<{}>
Snippet shfl should_set_the_flash_to /<{}>/i

" shoulda contexts
Snippet cont context "<{description}>" do<CR>setup do<CR><{}><CR>end<CR>end
Snippet sh should "<{description}>" do<CR><{}><CR>end

"rspec
Snippet desc ``DefaultSpecDescribe()`` "<{description}>" do<CR><{}><CR>end
Snippet descn describe <{class}> do<CR><{}><CR>end
Snippet bef before do<CR>{}<CR>end
Snippet let let(:<{actor}>) { <{}> }
Snippet it it "should <{description}>" do<CR><{}><CR>end
Snippet itsh it "should <{description}>" do<CR>``SpecSubject()``.should <{}><CR>end
Snippet itshbe it "should <{description}>" do<CR>``SpecSubject()``.should be_<{}><CR>end
Snippet atsh it "should <{description}>" do<CR>``SpecSubject()``.<{attr}>.should <{}><CR>end
Snippet atshbe it "should <{description}>" do<CR>``SpecSubject()``.<{attr}>.should be_<{}><CR>end
Snippet sheq should == <{}>
Snippet spechelper require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')<{}>

" rspec-rails
Snippet itres it { response.should be_<{}> }
Snippet itrend it { response.should render_template(:<{}>) }
Snippet itred it { response.should redirect_to(<{}>) }

"" rspec-rr
Snippet shrec should have_received.<{}>

" mocha
Snippet stubs stubs(:<{method}>).returns(<{result}>)
Snippet expects expects(:<{method}>).with(<{params}>).returns(<{result}>)<{}>
Snippet expectse expects(:<{method}>).with().returns(<{result}>)<{}>

" assertions
Snippet as assert <{}>
Snippet ase assert_equal <{expected}>, <{}>
Snippet asne assert_not_equal <{unexpected}>, <{}>
Snippet asn assert_nil <{}>
Snippet asnn assert_not_nil <{}>
Snippet asm assert_match <{expected}>, <{}>
Snippet asnm assert_match <{unexpected}>, <{}>
Snippet assel assert_select "<{}>"
Snippet asre assert_received(<{subject}>, :<{method}>) { |expect| expect.<{}> }

" render
Snippet renda render :action => '<{}>'
Snippet rendn render :nothing => true<{}>
Snippet rendf render :file => '<{}>'
Snippet rendt render :template => '<{}>'
Snippet rendl render :layout => '<{}>'

" Cucumber step definitions
Snippet Given Given /^<{step}>$/ do<{}><CR>end
Snippet When When /^<{step}>$/ do<{}><CR>end
Snippet Then Then /^<{step}>$/ do<{}><CR>end

" Search shortcuts
nmap m/ /^\s*\(def \\| def self\.\)
" Start a new method in a Ruby class
" <Leader>nm
nmap <Leader>nm gg/^\s\+\(private\\|protected\)\\|^end<Enter>kO<Enter>
" Align Ruby operators like hash rockets
vmap <buffer> <C-A> !align_ruby<CR>

0 comments on commit 95822b0

Please sign in to comment.