From d6c79720aebdb7f950f0ee4b5ac53935264e9649 Mon Sep 17 00:00:00 2001 From: yan Date: Thu, 8 Dec 2011 01:21:54 -0800 Subject: [PATCH] Moved ruby_focused_unit_test, pathogen to bundles, removed ragtag --- .gitmodules | 6 + vim/autoload/pathogen.vim | 230 --------- vim/autoload/ruby_focused_unit_test.vim | 174 ------- .../drewolson-ruby_focused_unit_test_vim | 1 + vim/bundle/tpope-vim-pathogen | 1 + vim/plugin/ragtag.vim | 486 ------------------ vim/plugin/ruby_focused_unit_test.vim | 182 ------- vimrc | 3 +- 8 files changed, 10 insertions(+), 1073 deletions(-) delete mode 100644 vim/autoload/pathogen.vim delete mode 100644 vim/autoload/ruby_focused_unit_test.vim create mode 160000 vim/bundle/drewolson-ruby_focused_unit_test_vim create mode 160000 vim/bundle/tpope-vim-pathogen delete mode 100644 vim/plugin/ragtag.vim delete mode 100644 vim/plugin/ruby_focused_unit_test.vim diff --git a/.gitmodules b/.gitmodules index 1efcfd6..ba40896 100644 --- a/.gitmodules +++ b/.gitmodules @@ -100,3 +100,9 @@ [submodule "vim/bundle/rson-vim-conque"] path = vim/bundle/rson-vim-conque url = https://github.com/rson/vim-conque.git +[submodule "vim/bundle/tpope-vim-pathogen"] + path = vim/bundle/tpope-vim-pathogen + url = https://github.com/tpope/vim-pathogen +[submodule "vim/bundle/drewolson-ruby_focused_unit_test_vim"] + path = vim/bundle/drewolson-ruby_focused_unit_test_vim + url = https://github.com/drewolson/ruby_focused_unit_test_vim diff --git a/vim/autoload/pathogen.vim b/vim/autoload/pathogen.vim deleted file mode 100644 index be68389..0000000 --- a/vim/autoload/pathogen.vim +++ /dev/null @@ -1,230 +0,0 @@ -" pathogen.vim - path option manipulation -" Maintainer: Tim Pope -" Version: 2.0 - -" Install in ~/.vim/autoload (or ~\vimfiles\autoload). -" -" For management of individually installed plugins in ~/.vim/bundle (or -" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc -" prior to `fileype plugin indent on` is the only other setup necessary. -" -" The API is documented inline below. For maximum ease of reading, -" :set foldmethod=marker - -if exists("g:loaded_pathogen") || &cp - finish -endif -let g:loaded_pathogen = 1 - -" Point of entry for basic default usage. Give a directory name to invoke -" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path -" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards, -" pathogen#cycle_filetype() is invoked. -function! pathogen#infect(...) abort " {{{1 - let source_path = a:0 ? a:1 : 'bundle' - if source_path =~# '[\\/]' - call pathogen#runtime_prepend_subdirectories(source_path) - else - call pathogen#runtime_append_all_bundles(source_path) - endif - call pathogen#cycle_filetype() -endfunction " }}}1 - -" Split a path into a list. -function! pathogen#split(path) abort " {{{1 - if type(a:path) == type([]) | return a:path | endif - let split = split(a:path,'\\\@,'edit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,'lcd') - -" vim:set ft=vim ts=8 sw=2 sts=2: diff --git a/vim/autoload/ruby_focused_unit_test.vim b/vim/autoload/ruby_focused_unit_test.vim deleted file mode 100644 index 49e881d..0000000 --- a/vim/autoload/ruby_focused_unit_test.vim +++ /dev/null @@ -1,174 +0,0 @@ -"if !has("ruby") -" finish -"end - -command RunRubyFocusedUnitTest :call RunRubyFocusedUnitTest() -command RunRubyFocusedContext :call RunRubyFocusedContext() -command RunAllRubyTests :call RunAllRubyTests() -command RunLastRubyTest :call RunLastRubyTest() - -function! s:RunRubyFocusedUnitTest() - ruby RubyFocusedUnitTest.new.run_test -endfunction - -function! s:RunRubyFocusedContext() - ruby RubyFocusedUnitTest.new.run_context -endfunction - -function! s:RunAllRubyTests() - ruby RubyFocusedUnitTest.new.run_all -endfunction - -function! s:RunLastRubyTest() - ruby RubyFocusedUnitTest.new.run_last -endfunction - -ruby << EOF -module VIM - class Buffer - class << self - include Enumerable - - def each(&block) - (0...VIM::Buffer.count).each do |index| - yield self[index] - end - end - - def create(name, opts={}) - location = opts[:location] || :below - VIM.command("#{location} new #{name}") - buf = VIM::Buffer.current - if opts[:text] - buf.text = opts[:text] - end - buf - end - end - - def text=(content) - content.split("\n").each_with_index do |line,index| - self.append index, line - end - end - - def method_missing(method, *args, &block) - VIM.command "#{method} #{self.name}" - end - end -end - -class RubyFocusedUnitTest - DEFAULT_OUTPUT_BUFFER = "rb_test_output" - SAVED_TEST_COMMAND_FILE = '/tmp/last_ruby_focused_unit_test' - - def write_output_to_buffer(test_command) - save_test_command(test_command) - - if buffer = VIM::Buffer.find { |b| b.name =~ /#{DEFAULT_OUTPUT_BUFFER}/ } - buffer.bdelete! - end - - buffer = VIM::Buffer.create DEFAULT_OUTPUT_BUFFER, :location => :below, :text => "--- Run Focused Unit Test ---\n\n" - VIM.command("setlocal buftype=nowrite") - VIM.command "redraw" - - IO.popen("#{test_command} 2>&1", "r") do |io| - begin - loop do - input = io.readpartial(10) - first, *rest = input.split(/\n/, -1) - buffer[buffer.length] = buffer[buffer.length] + first - rest.each {|l| buffer.append buffer.length, l } - VIM.command "redraw" - end - rescue EOFError - end - end - end - - def save_test_command(test_command) - File.open(SAVED_TEST_COMMAND_FILE, 'w') { |f| f.write(test_command) } - end - - def current_file - VIM::Buffer.current.name - end - - def spec_file? - current_file =~ /spec_|_spec/ - end - - def line_number - VIM::Buffer.current.line_number - end - - def run_spec - write_output_to_buffer("spec #{current_file} -l #{line_number}") - end - - def run_unit_test - method_name = nil - - (line_number + 1).downto(1) do |line_number| - if VIM::Buffer.current[line_number] =~ /def (test_\w+)/ - method_name = $1 - break - elsif VIM::Buffer.current[line_number] =~ /test "([^"]+)"/ || - VIM::Buffer.current[line_number] =~ /test '([^']+)'/ - method_name = "test_" + $1.split(" ").join("_") - break - elsif VIM::Buffer.current[line_number] =~ /should "([^"]+)"/ || - VIM::Buffer.current[line_number] =~ /should '([^']+)'/ - method_name = "\"/#{Regexp.escape($1)}/\"" - break - end - end - - write_output_to_buffer("ruby #{current_file} -n #{method_name}") if method_name - end - - def run_test - if spec_file? - run_spec - else - run_unit_test - end - end - - def run_context - method_name = nil - context_line_number = nil - - (line_number + 1).downto(1) do |line_number| - if VIM::Buffer.current[line_number] =~ /(context|describe) "([^"]+)"/ || - VIM::Buffer.current[line_number] =~ /(context|describe) '([^']+)'/ - method_name = $2 - context_line_number = line_number - break - end - end - - if method_name - if spec_file? - write_output_to_buffer("spec #{current_file} -l #{context_line_number}") - else - method_name = "\"/#{Regexp.escape(method_name)}/\"" - write_output_to_buffer("ruby #{current_file} -n #{method_name}") - end - end - end - - def run_all - if spec_file? - write_output_to_buffer("spec #{current_file}") - else - write_output_to_buffer("ruby #{current_file}") - end - end - - def run_last - write_output_to_buffer(File.read(SAVED_TEST_COMMAND_FILE)) - end -end -EOF diff --git a/vim/bundle/drewolson-ruby_focused_unit_test_vim b/vim/bundle/drewolson-ruby_focused_unit_test_vim new file mode 160000 index 0000000..980b2eb --- /dev/null +++ b/vim/bundle/drewolson-ruby_focused_unit_test_vim @@ -0,0 +1 @@ +Subproject commit 980b2ebad5d994ce44a7a765e734e1a3ffde3004 diff --git a/vim/bundle/tpope-vim-pathogen b/vim/bundle/tpope-vim-pathogen new file mode 160000 index 0000000..ab64b4d --- /dev/null +++ b/vim/bundle/tpope-vim-pathogen @@ -0,0 +1 @@ +Subproject commit ab64b4ddd0c184a528780b498a0b0a5b40248f7c diff --git a/vim/plugin/ragtag.vim b/vim/plugin/ragtag.vim deleted file mode 100644 index 3843cd9..0000000 --- a/vim/plugin/ragtag.vim +++ /dev/null @@ -1,486 +0,0 @@ -" ragtag.vim - Ghetto XML/HTML mappings (formerly allml.vim) -" Author: Tim Pope -" Version: 2.0 -" GetLatestVimScripts: 1896 1 :AutoInstall: ragtag.vim - -if exists("g:loaded_ragtag") || &cp - finish -endif -let g:loaded_ragtag = 1 - -if has("autocmd") - augroup ragtag - autocmd! - autocmd FileType *html*,wml,xml,xslt,xsd,jsp call s:Init() - autocmd FileType php,asp*,cf,mason,eruby call s:Init() - if version >= 700 - autocmd InsertLeave * call s:Leave() - endif - autocmd CursorHold * if exists("b:loaded_ragtag") | call s:Leave() | endif - augroup END -endif - -inoremap ragtagHtmlComplete =htmlEn()=htmlDis() - -" Public interface, for if you have your own filetypes to activate on -function! RagtagInit() - call s:Init() -endfunction - -function! AllmlInit() - call s:Init() -endfunction - -function! s:Init() - let b:loaded_ragtag = 1 - inoremap xmlversion =toupper(charset())"?> - inoremap htmltrans - inoremap xhtmltrans - if s:subtype() == "xml" - imap O - else - imap ] >O - endif - " <% %> - if &ft == "eruby" - inoremap - <%-%>3hi - inoremap _ I<%A-%>Fs - elseif &ft == "cf" - inoremap - - inoremap _ - else - imap - >2hi - imap _ IA>Fs - endif - " Comments - if &ft =~ '^asp' - imap ' '>2hi - imap " I'A>Fs - let b:surround_35 = maparg("","i")."' \r ".maparg(">","i") - elseif &ft == "jsp" - inoremap ' %----%>4hi - inoremap " I<%--A--%>Fs - let b:surround_35 = "<%-- \r --%>" - elseif &ft == "cf" - inoremap ' !------>4hi - inoremap " IFs - setlocal commentstring= - let b:surround_35 = "" - elseif &ft == "html" || &ft == "xml" || &ft == "xhtml" - inoremap ' !---->3hi - inoremap " IFs - let b:surround_35 = "" - elseif &ft == "django" - inoremap ' {##}2hi - inoremap " I{#A#}Fs - let b:surround_35 = "{# \r #}" - else - imap ' #>2hi - imap " I#A>Fs - let b:surround_35 = maparg("","i")."# \r ".maparg(">","i") - endif - imap % ragtagUrlEncode - imap & ragtagXmlEncode - imap % ragtagUrlV - imap & ragtagXmlV - if !exists("b:did_indent") - if s:subtype() == "xml" - runtime! indent/xml.vim - else - runtime! indent/html.vim - endif - endif - " Pet peeve. Do people still not close their

and

  • tags? - if exists("g:html_indent_tags") && g:html_indent_tags !~ '\\|p\>' - let g:html_indent_tags = g:html_indent_tags.'\|p\|li\|dt\|dd' - endif - set indentkeys+=!^F - let b:surround_indent = 1 - silent doautocmd User ragtag - silent doautocmd User allml -endfunction - -function! s:Leave() - call s:disableescape() -endfunction - -function! s:length(str) - return strlen(substitute(a:str,'.','.','g')) -endfunction - -function! s:repeat(str,cnt) - let cnt = a:cnt - let str = "" - while cnt > 0 - let str = str . a:str - let cnt = cnt - 1 - endwhile - return str -endfunction - -function! s:doctypeSeek() - if !exists("b:ragtag_doctype_index") - if exists("b:allml_doctype_index") - let b:ragtag_doctype_index = b:allml_doctype_index - elseif &ft == 'xhtml' || &ft == 'eruby' - let b:ragtag_doctype_index = 10 - elseif &ft != 'xml' - let b:ragtag_doctype_index = 7 - endif - endif - let index = b:ragtag_doctype_index - 1 - return (index < 0 ? s:repeat("\",-index) : s:repeat("\",index)) -endfunction - -function! s:stylesheetTag() - if !exists("b:ragtag_stylesheet_link_tag") - if exists("b:allml_stylesheet_link_tag") - let b:ragtag_stylesheet_link_tag = b:allml_stylesheet_link_tag - else - let b:ragtag_stylesheet_link_tag = "" - endif - endif - return s:insertTag(b:ragtag_stylesheet_link_tag) -endfunction - -function! s:javascriptIncludeTag() - if !exists("b:ragtag_javascript_include_tag") - if exists("b:allml_javascript_include_tag") - let b:ragtag_javascript_include_tag = b:allml_javascript_include_tag - else - let b:ragtag_javascript_include_tag = "" - endif - endif - return s:insertTag(b:ragtag_javascript_include_tag) -endfunction - -function! s:insertTag(tag) - let tag = a:tag - if s:subtype() == "html" - let tag = substitute(a:tag,'\s*/>','>','g') - endif - let before = matchstr(tag,'^.\{-\}\ze\r') - let after = matchstr(tag,'\r\zs\%(.*\r\)\@!.\{-\}$') - " middle isn't currently used - let middle = matchstr(tag,'\r\zs.\{-\}\ze\r') - return before.after.s:repeat("\",s:length(after)) -endfunction - - -function! s:htmlEn() - let b:ragtag_omni = &l:omnifunc - let b:ragtag_isk = &l:isk - " : is for namespaced xml attributes - setlocal omnifunc=htmlcomplete#CompleteTags isk+=: - return "" -endfunction - -function! s:htmlDis() - if exists("b:ragtag_omni") - let &l:omnifunc = b:ragtag_omni - unlet b:ragtag_omni - endif - if exists("b:ragtag_isk") - let &l:isk = b:ragtag_isk - unlet b:ragtag_isk - endif - return "" -endfunction - -function! s:subtype() - let top = getline(1)."\n".getline(2) - if (top =~ '' && &ft !~? 'html') || &ft =~? '^\%(xml\|xsd\|xslt\)$' - return "xml" - elseif top =~? '\' - return 'xhtml' - elseif top =~ '[^<]\' - return "html" - elseif &ft == "xhtml" || &ft == "eruby" - return "xhtml" - elseif exists("b:loaded_ragtag") - return "html" - else - return "" - endif -endfunction - -function! s:closetagback() - if s:subtype() == "html" - return ">\" - else - return " />\\\" - endif -endfunction - -function! s:closetag() - if s:subtype() == "html" - return ">" - else - return " />" - endif -endfunction - -function! s:charset() - let enc = &fileencoding - if enc == "" - let enc = &encoding - endif - if enc == "latin1" - return "ISO-8859-1" - elseif enc == "" - return "US-ASCII" - else - return enc - endif -endfunction - -function! s:tagextras() - if s:subtype() == "xml" - return "" - elseif @" == 'html' && s:subtype() == 'xhtml' - let lang = "en" - if exists("$LANG") && $LANG =~ '^..' - let lang = strpart($LANG,0,2) - endif - return ' xmlns="http://www.w3.org/1999/xhtml" lang="'.lang.'" xml:lang="'.lang.'"' - elseif @" == 'style' - return ' type="text/css"' - elseif @" == 'script' - return ' type="text/javascript"' - elseif @" == 'table' - return ' cellspacing="0"' - else - return "" - endif -endfunction - -inoremap urlspace =getinput()=~?'\%([?&]\&\)[%a-z0-9._~+-]*=[%a-z0-9._~+-]*$'?'+':'%20' - -function! s:urltab(htmlesc) - let line = s:getinput() - let g:line = line - if line =~ '[^ <>"'."'".']\@"'."'".']\@ ragtagBSUrl - inoremap %0A - imap