tomkersten-vixploder 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +105 -0
- data/PostInstall.txt +21 -0
- data/README.rdoc +131 -0
- data/Rakefile +21 -0
- data/bin/256colors2.pl +63 -0
- data/bin/colortest +365 -0
- data/bin/vixplode +10 -0
- data/lib/dotfiles/aliases +30 -0
- data/lib/dotfiles/gvimrc +20 -0
- data/lib/dotfiles/vim/.VimballRecord +2 -0
- data/lib/dotfiles/vim/after/ftplugin/actionscript_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/aspvbs_snippets.vim +17 -0
- data/lib/dotfiles/vim/after/ftplugin/c_snippets.vim +58 -0
- data/lib/dotfiles/vim/after/ftplugin/css_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/django_model_snippets.vim +61 -0
- data/lib/dotfiles/vim/after/ftplugin/django_template_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/f-script_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/haskell_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/html_snippets.vim +57 -0
- data/lib/dotfiles/vim/after/ftplugin/java_snippets.vim +52 -0
- data/lib/dotfiles/vim/after/ftplugin/javascript_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/latex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/logo_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/markdown_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/movable_type_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/objc_snippets.vim +53 -0
- data/lib/dotfiles/vim/after/ftplugin/ocaml_snippets.vim +26 -0
- data/lib/dotfiles/vim/after/ftplugin/perl_snippets.vim +23 -0
- data/lib/dotfiles/vim/after/ftplugin/php_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/phpdoc_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/propel_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/python_snippets.vim +202 -0
- data/lib/dotfiles/vim/after/ftplugin/rails_snippets.vim +54 -0
- data/lib/dotfiles/vim/after/ftplugin/ruby_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/sh_snippets.vim +12 -0
- data/lib/dotfiles/vim/after/ftplugin/slate_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/smarty_snippets.vim +35 -0
- data/lib/dotfiles/vim/after/ftplugin/symfony_snippets.vim +21 -0
- data/lib/dotfiles/vim/after/ftplugin/tcl_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/template_toolkit_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/tex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/xhtml_snippets.vim +48 -0
- data/lib/dotfiles/vim/autoload/fakeclip.vim +253 -0
- data/lib/dotfiles/vim/autoload/rails.vim +4377 -0
- data/lib/dotfiles/vim/autoload/rubycomplete.vim +802 -0
- data/lib/dotfiles/vim/colors/inkpot.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black_mod.vim +213 -0
- data/lib/dotfiles/vim/colors/railscasts.vim +100 -0
- data/lib/dotfiles/vim/colors/rubyblue.vim +74 -0
- data/lib/dotfiles/vim/colors/twilight.vim +75 -0
- data/lib/dotfiles/vim/colors/twilight2.vim +74 -0
- data/lib/dotfiles/vim/colors/wombat256.vim +302 -0
- data/lib/dotfiles/vim/compiler/eruby.vim +41 -0
- data/lib/dotfiles/vim/compiler/ruby.vim +68 -0
- data/lib/dotfiles/vim/compiler/rubyunit.vim +35 -0
- data/lib/dotfiles/vim/doc/NERD_tree.txt +1235 -0
- data/lib/dotfiles/vim/doc/fakeclip.txt +190 -0
- data/lib/dotfiles/vim/doc/matchit.txt +406 -0
- data/lib/dotfiles/vim/doc/project.txt +710 -0
- data/lib/dotfiles/vim/doc/rails.txt +1123 -0
- data/lib/dotfiles/vim/doc/snippets_emu.txt +354 -0
- data/lib/dotfiles/vim/doc/surround.txt +218 -0
- data/lib/dotfiles/vim/doc/tags +433 -0
- data/lib/dotfiles/vim/filetype.vim +13 -0
- data/lib/dotfiles/vim/ftdetect/gist.vim +3 -0
- data/lib/dotfiles/vim/ftdetect/ruby.vim +14 -0
- data/lib/dotfiles/vim/ftplugin/eruby.vim +101 -0
- data/lib/dotfiles/vim/ftplugin/ruby.vim +230 -0
- data/lib/dotfiles/vim/indent/eruby.vim +73 -0
- data/lib/dotfiles/vim/indent/ruby.vim +373 -0
- data/lib/dotfiles/vim/plugin/NERD_tree.vim +3536 -0
- data/lib/dotfiles/vim/plugin/comments.vim +321 -0
- data/lib/dotfiles/vim/plugin/fakeclip.vim +174 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder.vim +1676 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder_textmate.vim +150 -0
- data/lib/dotfiles/vim/plugin/gist.vim +241 -0
- data/lib/dotfiles/vim/plugin/gitdiff.vim +141 -0
- data/lib/dotfiles/vim/plugin/matchit.vim +812 -0
- data/lib/dotfiles/vim/plugin/mru.vim +787 -0
- data/lib/dotfiles/vim/plugin/rails.vim +310 -0
- data/lib/dotfiles/vim/plugin/rspec.vim +12 -0
- data/lib/dotfiles/vim/plugin/snippets.vim +17 -0
- data/lib/dotfiles/vim/plugin/snippetsEmu.vim +973 -0
- data/lib/dotfiles/vim/plugin/supertab.vim +531 -0
- data/lib/dotfiles/vim/plugin/surround.vim +632 -0
- data/lib/dotfiles/vim/ref_vimrc +80 -0
- data/lib/dotfiles/vim/ruby/fuzzy_file_finder.rb +353 -0
- data/lib/dotfiles/vim/syntax/eruby.vim +85 -0
- data/lib/dotfiles/vim/syntax/haml.vim +113 -0
- data/lib/dotfiles/vim/syntax/mkd.vim +86 -0
- data/lib/dotfiles/vim/syntax/ruby.vim +324 -0
- data/lib/dotfiles/vim/syntax/sass.vim +93 -0
- data/lib/dotfiles/vimrc +269 -0
- data/lib/vixplode/cli.rb +73 -0
- data/lib/vixploder.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/vixplode_cli_spec.rb +15 -0
- data/spec/vixploder_spec.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +202 -8
@@ -0,0 +1,14 @@
|
|
1
|
+
" Ruby
|
2
|
+
au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec set filetype=ruby
|
3
|
+
|
4
|
+
" Ruby on Rails
|
5
|
+
au BufNewFile,BufRead *.builder,*.rxml,*.rjs set filetype=ruby
|
6
|
+
|
7
|
+
" Rakefile
|
8
|
+
au BufNewFile,BufRead [rR]akefile,*.rake set filetype=ruby
|
9
|
+
|
10
|
+
" Rantfile
|
11
|
+
au BufNewFile,BufRead [rR]antfile,*.rant set filetype=ruby
|
12
|
+
|
13
|
+
" eRuby
|
14
|
+
au BufNewFile,BufRead *.erb,*.rhtml set filetype=eruby
|
@@ -0,0 +1,101 @@
|
|
1
|
+
" Vim filetype plugin
|
2
|
+
" Language: eRuby
|
3
|
+
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
4
|
+
" Info: $Id: eruby.vim,v 1.10 2007/05/06 16:05:40 tpope Exp $
|
5
|
+
" URL: http://vim-ruby.rubyforge.org
|
6
|
+
" Anon CVS: See above site
|
7
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
8
|
+
|
9
|
+
" Only do this when not done yet for this buffer
|
10
|
+
if exists("b:did_ftplugin")
|
11
|
+
finish
|
12
|
+
endif
|
13
|
+
|
14
|
+
let s:save_cpo = &cpo
|
15
|
+
set cpo-=C
|
16
|
+
|
17
|
+
" Define some defaults in case the included ftplugins don't set them.
|
18
|
+
let s:undo_ftplugin = ""
|
19
|
+
let s:browsefilter = "All Files (*.*)\t*.*\n"
|
20
|
+
let s:match_words = ""
|
21
|
+
|
22
|
+
if !exists("g:eruby_default_subtype")
|
23
|
+
let g:eruby_default_subtype = "html"
|
24
|
+
endif
|
25
|
+
|
26
|
+
if !exists("b:eruby_subtype")
|
27
|
+
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
28
|
+
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
29
|
+
if b:eruby_subtype == ''
|
30
|
+
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\)\+$','',''),'\.\zs\w\+$')
|
31
|
+
endif
|
32
|
+
if b:eruby_subtype == 'rhtml'
|
33
|
+
let b:eruby_subtype = 'html'
|
34
|
+
elseif b:eruby_subtype == 'rb'
|
35
|
+
let b:eruby_subtype = 'ruby'
|
36
|
+
elseif b:eruby_subtype == 'yml'
|
37
|
+
let b:eruby_subtype = 'yaml'
|
38
|
+
elseif b:eruby_subtype == 'js'
|
39
|
+
let b:eruby_subtype = 'javascript'
|
40
|
+
elseif b:eruby_subtype == 'txt'
|
41
|
+
" Conventional; not a real file type
|
42
|
+
let b:eruby_subtype = 'text'
|
43
|
+
elseif b:eruby_subtype == ''
|
44
|
+
let b:eruby_subtype = g:eruby_default_subtype
|
45
|
+
endif
|
46
|
+
endif
|
47
|
+
|
48
|
+
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
49
|
+
exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
|
50
|
+
else
|
51
|
+
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
52
|
+
endif
|
53
|
+
unlet! b:did_ftplugin
|
54
|
+
|
55
|
+
" Override our defaults if these were set by an included ftplugin.
|
56
|
+
if exists("b:undo_ftplugin")
|
57
|
+
let s:undo_ftplugin = b:undo_ftplugin
|
58
|
+
unlet b:undo_ftplugin
|
59
|
+
endif
|
60
|
+
if exists("b:browsefilter")
|
61
|
+
let s:browsefilter = b:browsefilter
|
62
|
+
unlet b:browsefilter
|
63
|
+
endif
|
64
|
+
if exists("b:match_words")
|
65
|
+
let s:match_words = b:match_words
|
66
|
+
unlet b:match_words
|
67
|
+
endif
|
68
|
+
|
69
|
+
runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim
|
70
|
+
let b:did_ftplugin = 1
|
71
|
+
|
72
|
+
" Combine the new set of values with those previously included.
|
73
|
+
if exists("b:undo_ftplugin")
|
74
|
+
let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
|
75
|
+
endif
|
76
|
+
if exists ("b:browsefilter")
|
77
|
+
let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
|
78
|
+
endif
|
79
|
+
if exists("b:match_words")
|
80
|
+
let s:match_words = b:match_words . ',' . s:match_words
|
81
|
+
endif
|
82
|
+
|
83
|
+
" Change the browse dialog on Win32 to show mainly eRuby-related files
|
84
|
+
if has("gui_win32")
|
85
|
+
let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter
|
86
|
+
endif
|
87
|
+
|
88
|
+
" Load the combined list of match_words for matchit.vim
|
89
|
+
if exists("loaded_matchit")
|
90
|
+
let b:match_words = s:match_words
|
91
|
+
endif
|
92
|
+
|
93
|
+
" TODO: comments=
|
94
|
+
setlocal commentstring=<%#%s%>
|
95
|
+
|
96
|
+
let b:undo_ftplugin = "setl cms< "
|
97
|
+
\ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
|
98
|
+
|
99
|
+
let &cpo = s:save_cpo
|
100
|
+
|
101
|
+
" vim: nowrap sw=2 sts=2 ts=8 ff=unix:
|
@@ -0,0 +1,230 @@
|
|
1
|
+
" Vim filetype plugin
|
2
|
+
" Language: Ruby
|
3
|
+
" Maintainer: Gavin Sinclair <gsinclair at gmail.com>
|
4
|
+
" Info: $Id: ruby.vim,v 1.39 2007/05/06 16:38:40 tpope Exp $
|
5
|
+
" URL: http://vim-ruby.rubyforge.org
|
6
|
+
" Anon CVS: See above site
|
7
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
8
|
+
" ----------------------------------------------------------------------------
|
9
|
+
"
|
10
|
+
" Original matchit support thanks to Ned Konz. See his ftplugin/ruby.vim at
|
11
|
+
" http://bike-nomad.com/vim/ruby.vim.
|
12
|
+
" ----------------------------------------------------------------------------
|
13
|
+
|
14
|
+
" Only do this when not done yet for this buffer
|
15
|
+
if (exists("b:did_ftplugin"))
|
16
|
+
finish
|
17
|
+
endif
|
18
|
+
let b:did_ftplugin = 1
|
19
|
+
|
20
|
+
let s:cpo_save = &cpo
|
21
|
+
set cpo&vim
|
22
|
+
|
23
|
+
if has("gui_running") && !has("gui_win32")
|
24
|
+
setlocal keywordprg=ri\ -T
|
25
|
+
else
|
26
|
+
setlocal keywordprg=ri
|
27
|
+
endif
|
28
|
+
|
29
|
+
" Matchit support
|
30
|
+
if exists("loaded_matchit") && !exists("b:match_words")
|
31
|
+
let b:match_ignorecase = 0
|
32
|
+
|
33
|
+
let b:match_words =
|
34
|
+
\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' .
|
35
|
+
\ ':' .
|
36
|
+
\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
|
37
|
+
\ ':' .
|
38
|
+
\ '\<end\>' .
|
39
|
+
\ ',{:},\[:\],(:)'
|
40
|
+
|
41
|
+
let b:match_skip =
|
42
|
+
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
|
43
|
+
\ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
|
44
|
+
\ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
|
45
|
+
\ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
|
46
|
+
\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
|
47
|
+
\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
|
48
|
+
endif
|
49
|
+
|
50
|
+
setlocal formatoptions-=t formatoptions+=croql
|
51
|
+
|
52
|
+
setlocal include=^\\s*\\<\\(load\\\|\w*require\\)\\>
|
53
|
+
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','')
|
54
|
+
setlocal suffixesadd=.rb
|
55
|
+
|
56
|
+
if exists("&ofu") && has("ruby")
|
57
|
+
setlocal omnifunc=rubycomplete#Complete
|
58
|
+
endif
|
59
|
+
|
60
|
+
" To activate, :set ballooneval
|
61
|
+
if has('balloon_eval') && exists('+balloonexpr')
|
62
|
+
setlocal balloonexpr=RubyBalloonexpr()
|
63
|
+
endif
|
64
|
+
|
65
|
+
|
66
|
+
" TODO:
|
67
|
+
"setlocal define=^\\s*def
|
68
|
+
|
69
|
+
setlocal comments=:#
|
70
|
+
setlocal commentstring=#\ %s
|
71
|
+
|
72
|
+
if !exists("s:rubypath")
|
73
|
+
if has("ruby") && has("win32")
|
74
|
+
ruby VIM::command( 'let s:rubypath = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
|
75
|
+
let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
|
76
|
+
elseif executable("ruby")
|
77
|
+
let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
|
78
|
+
if &shellxquote == "'"
|
79
|
+
let s:rubypath = system('ruby -e "' . s:code . '"')
|
80
|
+
else
|
81
|
+
let s:rubypath = system("ruby -e '" . s:code . "'")
|
82
|
+
endif
|
83
|
+
let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
|
84
|
+
else
|
85
|
+
" If we can't call ruby to get its path, just default to using the
|
86
|
+
" current directory and the directory of the current file.
|
87
|
+
let s:rubypath = ".,,"
|
88
|
+
endif
|
89
|
+
endif
|
90
|
+
|
91
|
+
let &l:path = s:rubypath
|
92
|
+
|
93
|
+
if has("gui_win32") && !exists("b:browsefilter")
|
94
|
+
let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
|
95
|
+
\ "All Files (*.*)\t*.*\n"
|
96
|
+
endif
|
97
|
+
|
98
|
+
let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< kp<"
|
99
|
+
\."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
|
100
|
+
\."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
|
101
|
+
\."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
|
102
|
+
|
103
|
+
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
|
104
|
+
|
105
|
+
noremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b')<CR>
|
106
|
+
noremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','')<CR>
|
107
|
+
noremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b')<CR>
|
108
|
+
noremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','')<CR>
|
109
|
+
|
110
|
+
noremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b')<CR>
|
111
|
+
noremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','')<CR>
|
112
|
+
noremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b')<CR>
|
113
|
+
noremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','')<CR>
|
114
|
+
|
115
|
+
let b:undo_ftplugin = b:undo_ftplugin
|
116
|
+
\."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
|
117
|
+
\."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
|
118
|
+
endif
|
119
|
+
|
120
|
+
let &cpo = s:cpo_save
|
121
|
+
unlet s:cpo_save
|
122
|
+
|
123
|
+
if exists("g:did_ruby_ftplugin_functions")
|
124
|
+
finish
|
125
|
+
endif
|
126
|
+
let g:did_ruby_ftplugin_functions = 1
|
127
|
+
|
128
|
+
function! RubyBalloonexpr()
|
129
|
+
if !exists('s:ri_found')
|
130
|
+
let s:ri_found = executable('ri')
|
131
|
+
endif
|
132
|
+
if s:ri_found
|
133
|
+
let line = getline(v:beval_lnum)
|
134
|
+
let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$')
|
135
|
+
let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g')
|
136
|
+
let str = b.a
|
137
|
+
let before = strpart(line,0,v:beval_col-strlen(b))
|
138
|
+
let after = strpart(line,v:beval_col+strlen(a))
|
139
|
+
if str =~ '^\.'
|
140
|
+
let str = substitute(str,'^\.','#','g')
|
141
|
+
if before =~ '\]\s*$'
|
142
|
+
let str = 'Array'.str
|
143
|
+
elseif before =~ '}\s*$'
|
144
|
+
" False positives from blocks here
|
145
|
+
let str = 'Hash'.str
|
146
|
+
elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$'
|
147
|
+
let str = 'String'.str
|
148
|
+
elseif before =~ '\$\d\+\.\d\+\s*$'
|
149
|
+
let str = 'Float'.str
|
150
|
+
elseif before =~ '\$\d\+\s*$'
|
151
|
+
let str = 'Integer'.str
|
152
|
+
elseif before =~ '/\s*$'
|
153
|
+
let str = 'Regexp'.str
|
154
|
+
else
|
155
|
+
let str = substitute(str,'^#','.','')
|
156
|
+
endif
|
157
|
+
endif
|
158
|
+
let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','')
|
159
|
+
let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','')
|
160
|
+
let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','')
|
161
|
+
let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','')
|
162
|
+
let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','')
|
163
|
+
let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','')
|
164
|
+
if str !~ '^\w'
|
165
|
+
return ''
|
166
|
+
endif
|
167
|
+
silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','')
|
168
|
+
if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method'
|
169
|
+
return ''
|
170
|
+
endif
|
171
|
+
return res
|
172
|
+
else
|
173
|
+
return ""
|
174
|
+
endif
|
175
|
+
endfunction
|
176
|
+
|
177
|
+
function! s:searchsyn(pattern,syn,flags)
|
178
|
+
norm! m'
|
179
|
+
let i = 0
|
180
|
+
let cnt = v:count ? v:count : 1
|
181
|
+
while i < cnt
|
182
|
+
let i = i + 1
|
183
|
+
let line = line('.')
|
184
|
+
let col = col('.')
|
185
|
+
let pos = search(a:pattern,'W'.a:flags)
|
186
|
+
while pos != 0 && s:synname() !~# a:syn
|
187
|
+
let pos = search(a:pattern,'W'.a:flags)
|
188
|
+
endwhile
|
189
|
+
if pos == 0
|
190
|
+
call cursor(line,col)
|
191
|
+
return
|
192
|
+
endif
|
193
|
+
endwhile
|
194
|
+
endfunction
|
195
|
+
|
196
|
+
function! s:synname()
|
197
|
+
return synIDattr(synID(line('.'),col('.'),0),'name')
|
198
|
+
endfunction
|
199
|
+
|
200
|
+
"
|
201
|
+
" Instructions for enabling "matchit" support:
|
202
|
+
"
|
203
|
+
" 1. Look for the latest "matchit" plugin at
|
204
|
+
"
|
205
|
+
" http://www.vim.org/scripts/script.php?script_id=39
|
206
|
+
"
|
207
|
+
" It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
|
208
|
+
"
|
209
|
+
" 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
|
210
|
+
"
|
211
|
+
" 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
|
212
|
+
"
|
213
|
+
" 4. Ensure this file (ftplugin/ruby.vim) is installed.
|
214
|
+
"
|
215
|
+
" 5. Ensure you have this line in your $HOME/.vimrc:
|
216
|
+
" filetype plugin on
|
217
|
+
"
|
218
|
+
" 6. Restart Vim and create the matchit documentation:
|
219
|
+
"
|
220
|
+
" :helptags ~/.vim/doc
|
221
|
+
"
|
222
|
+
" Now you can do ":help matchit", and you should be able to use "%" on Ruby
|
223
|
+
" keywords. Try ":echo b:match_words" to be sure.
|
224
|
+
"
|
225
|
+
" Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the
|
226
|
+
" locations of plugin directories, etc., as there are several options, and it
|
227
|
+
" differs on Windows. Email gsinclair@soyabean.com.au if you need help.
|
228
|
+
"
|
229
|
+
|
230
|
+
" vim: nowrap sw=2 sts=2 ts=8 ff=unix:
|
@@ -0,0 +1,73 @@
|
|
1
|
+
" Vim indent file
|
2
|
+
" Language: eRuby
|
3
|
+
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
4
|
+
" Info: $Id: eruby.vim,v 1.9 2007/04/16 17:03:36 tpope Exp $
|
5
|
+
" URL: http://vim-ruby.rubyforge.org
|
6
|
+
" Anon CVS: See above site
|
7
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
8
|
+
|
9
|
+
if exists("b:did_indent")
|
10
|
+
finish
|
11
|
+
endif
|
12
|
+
|
13
|
+
runtime! indent/ruby.vim
|
14
|
+
unlet! b:did_indent
|
15
|
+
set indentexpr=
|
16
|
+
|
17
|
+
if exists("b:eruby_subtype")
|
18
|
+
exe "runtime! indent/".b:eruby_subtype.".vim"
|
19
|
+
else
|
20
|
+
runtime! indent/html.vim
|
21
|
+
endif
|
22
|
+
unlet! b:did_indent
|
23
|
+
|
24
|
+
if &l:indentexpr == ''
|
25
|
+
if &l:cindent
|
26
|
+
let &l:indentexpr = 'cindent(v:lnum)'
|
27
|
+
else
|
28
|
+
let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
|
29
|
+
endif
|
30
|
+
endif
|
31
|
+
let b:eruby_subtype_indentexpr = &l:indentexpr
|
32
|
+
|
33
|
+
let b:did_indent = 1
|
34
|
+
|
35
|
+
setlocal indentexpr=GetErubyIndent()
|
36
|
+
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when
|
37
|
+
|
38
|
+
" Only define the function once.
|
39
|
+
if exists("*GetErubyIndent")
|
40
|
+
finish
|
41
|
+
endif
|
42
|
+
|
43
|
+
function! GetErubyIndent()
|
44
|
+
let vcol = col('.')
|
45
|
+
call cursor(v:lnum,1)
|
46
|
+
let inruby = searchpair('<%','','%>')
|
47
|
+
call cursor(v:lnum,vcol)
|
48
|
+
if inruby && getline(v:lnum) !~ '^<%'
|
49
|
+
let ind = GetRubyIndent()
|
50
|
+
else
|
51
|
+
exe "let ind = ".b:eruby_subtype_indentexpr
|
52
|
+
endif
|
53
|
+
let lnum = prevnonblank(v:lnum-1)
|
54
|
+
let line = getline(lnum)
|
55
|
+
let cline = getline(v:lnum)
|
56
|
+
if cline =~# '<%\s*\%(end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)'
|
57
|
+
let ind = ind - &sw
|
58
|
+
endif
|
59
|
+
if line =~# '\<do\%(\s*|[^|]*|\)\=\s*-\=%>'
|
60
|
+
let ind = ind + &sw
|
61
|
+
elseif line =~# '<%\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
|
62
|
+
let ind = ind + &sw
|
63
|
+
endif
|
64
|
+
if line =~# '^\s*<%[=#]\=\s*$' && cline !~# '^\s*end\>'
|
65
|
+
let ind = ind + &sw
|
66
|
+
endif
|
67
|
+
if cline =~# '^\s*-\=%>\s*$'
|
68
|
+
let ind = ind - &sw
|
69
|
+
endif
|
70
|
+
return ind
|
71
|
+
endfunction
|
72
|
+
|
73
|
+
" vim:set sw=2 sts=2 ts=8 noet ff=unix:
|
@@ -0,0 +1,373 @@
|
|
1
|
+
" Vim indent file
|
2
|
+
" Language: Ruby
|
3
|
+
" Maintainer: Nikolai Weibull <now at bitwi.se>
|
4
|
+
" Info: $Id: ruby.vim,v 1.40 2007/03/20 13:54:25 dkearns Exp $
|
5
|
+
" URL: http://vim-ruby.rubyforge.org
|
6
|
+
" Anon CVS: See above site
|
7
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
8
|
+
|
9
|
+
" 0. Initialization {{{1
|
10
|
+
" =================
|
11
|
+
|
12
|
+
" Only load this indent file when no other was loaded.
|
13
|
+
if exists("b:did_indent")
|
14
|
+
finish
|
15
|
+
endif
|
16
|
+
let b:did_indent = 1
|
17
|
+
|
18
|
+
setlocal nosmartindent
|
19
|
+
|
20
|
+
" Now, set up our indentation expression and keys that trigger it.
|
21
|
+
setlocal indentexpr=GetRubyIndent()
|
22
|
+
setlocal indentkeys=0{,0},0),0],!^F,o,O,e
|
23
|
+
setlocal indentkeys+==end,=elsif,=when,=ensure,=rescue,==begin,==end
|
24
|
+
|
25
|
+
" Only define the function once.
|
26
|
+
if exists("*GetRubyIndent")
|
27
|
+
finish
|
28
|
+
endif
|
29
|
+
|
30
|
+
let s:cpo_save = &cpo
|
31
|
+
set cpo&vim
|
32
|
+
|
33
|
+
" 1. Variables {{{1
|
34
|
+
" ============
|
35
|
+
|
36
|
+
" Regex of syntax group names that are or delimit string or are comments.
|
37
|
+
let s:syng_strcom = '\<ruby\%(String\|StringDelimiter\|ASCIICode' .
|
38
|
+
\ '\|Interpolation\|NoInterpolation\|Escape\|Comment\|Documentation\)\>'
|
39
|
+
|
40
|
+
" Regex of syntax group names that are strings.
|
41
|
+
let s:syng_string =
|
42
|
+
\ '\<ruby\%(String\|StringDelimiter\|Interpolation\|NoInterpolation\|Escape\)\>'
|
43
|
+
|
44
|
+
" Regex of syntax group names that are strings or documentation.
|
45
|
+
let s:syng_stringdoc =
|
46
|
+
\'\<ruby\%(String\|StringDelimiter\|Interpolation\|NoInterpolation\|Escape\|Documentation\)\>'
|
47
|
+
|
48
|
+
" Expression used to check whether we should skip a match with searchpair().
|
49
|
+
let s:skip_expr =
|
50
|
+
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '".s:syng_strcom."'"
|
51
|
+
|
52
|
+
" Regex used for words that, at the start of a line, add a level of indent.
|
53
|
+
let s:ruby_indent_keywords = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
|
54
|
+
\ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure' .
|
55
|
+
\ '\|rescue\)\>' .
|
56
|
+
\ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' .
|
57
|
+
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>'
|
58
|
+
|
59
|
+
" Regex used for words that, at the start of a line, remove a level of indent.
|
60
|
+
let s:ruby_deindent_keywords =
|
61
|
+
\ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\)\>'
|
62
|
+
|
63
|
+
" Regex that defines the start-match for the 'end' keyword.
|
64
|
+
"let s:end_start_regex = '\%(^\|[^.]\)\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\|do\)\>'
|
65
|
+
" TODO: the do here should be restricted somewhat (only at end of line)?
|
66
|
+
let s:end_start_regex = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
|
67
|
+
\ '\|while\|until\|case\|unless\|begin\)\>' .
|
68
|
+
\ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' .
|
69
|
+
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>' .
|
70
|
+
\ '\|\<do\>'
|
71
|
+
|
72
|
+
" Regex that defines the middle-match for the 'end' keyword.
|
73
|
+
let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue\>\|when\|elsif\)\>'
|
74
|
+
|
75
|
+
" Regex that defines the end-match for the 'end' keyword.
|
76
|
+
let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end\>'
|
77
|
+
|
78
|
+
" Expression used for searchpair() call for finding match for 'end' keyword.
|
79
|
+
let s:end_skip_expr = s:skip_expr .
|
80
|
+
\ ' || (expand("<cword>") == "do"' .
|
81
|
+
\ ' && getline(".") =~ "^\\s*\\<while\\|until\\|for\\>")'
|
82
|
+
|
83
|
+
" Regex that defines continuation lines, not including (, {, or [.
|
84
|
+
let s:continuation_regex = '\%([\\*+/.,=:-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
85
|
+
|
86
|
+
" Regex that defines continuation lines.
|
87
|
+
" TODO: this needs to deal with if ...: and so on
|
88
|
+
let s:continuation_regex2 =
|
89
|
+
\ '\%([\\*+/.,=:({[-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
90
|
+
|
91
|
+
" Regex that defines blocks.
|
92
|
+
let s:block_regex =
|
93
|
+
\ '\%(\<do\>\|{\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=\s*\%(#.*\)\=$'
|
94
|
+
|
95
|
+
" 2. Auxiliary Functions {{{1
|
96
|
+
" ======================
|
97
|
+
|
98
|
+
" Check if the character at lnum:col is inside a string, comment, or is ascii.
|
99
|
+
function s:IsInStringOrComment(lnum, col)
|
100
|
+
return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_strcom
|
101
|
+
endfunction
|
102
|
+
|
103
|
+
" Check if the character at lnum:col is inside a string.
|
104
|
+
function s:IsInString(lnum, col)
|
105
|
+
return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_string
|
106
|
+
endfunction
|
107
|
+
|
108
|
+
" Check if the character at lnum:col is inside a string or documentation.
|
109
|
+
function s:IsInStringOrDocumentation(lnum, col)
|
110
|
+
return synIDattr(synID(a:lnum, a:col, 0), 'name') =~ s:syng_stringdoc
|
111
|
+
endfunction
|
112
|
+
|
113
|
+
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
|
114
|
+
function s:PrevNonBlankNonString(lnum)
|
115
|
+
let in_block = 0
|
116
|
+
let lnum = prevnonblank(a:lnum)
|
117
|
+
while lnum > 0
|
118
|
+
" Go in and out of blocks comments as necessary.
|
119
|
+
" If the line isn't empty (with opt. comment) or in a string, end search.
|
120
|
+
let line = getline(lnum)
|
121
|
+
if line =~ '^=begin$'
|
122
|
+
if in_block
|
123
|
+
let in_block = 0
|
124
|
+
else
|
125
|
+
break
|
126
|
+
endif
|
127
|
+
elseif !in_block && line =~ '^=end$'
|
128
|
+
let in_block = 1
|
129
|
+
elseif !in_block && line !~ '^\s*#.*$' && !(s:IsInStringOrComment(lnum, 1)
|
130
|
+
\ && s:IsInStringOrComment(lnum, strlen(line)))
|
131
|
+
break
|
132
|
+
endif
|
133
|
+
let lnum = prevnonblank(lnum - 1)
|
134
|
+
endwhile
|
135
|
+
return lnum
|
136
|
+
endfunction
|
137
|
+
|
138
|
+
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
|
139
|
+
function s:GetMSL(lnum)
|
140
|
+
" Start on the line we're at and use its indent.
|
141
|
+
let msl = a:lnum
|
142
|
+
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
|
143
|
+
while lnum > 0
|
144
|
+
" If we have a continuation line, or we're in a string, use line as MSL.
|
145
|
+
" Otherwise, terminate search as we have found our MSL already.
|
146
|
+
let line = getline(lnum)
|
147
|
+
let col = match(line, s:continuation_regex2) + 1
|
148
|
+
if (col > 0 && !s:IsInStringOrComment(lnum, col))
|
149
|
+
\ || s:IsInString(lnum, strlen(line))
|
150
|
+
let msl = lnum
|
151
|
+
else
|
152
|
+
break
|
153
|
+
endif
|
154
|
+
let lnum = s:PrevNonBlankNonString(lnum - 1)
|
155
|
+
endwhile
|
156
|
+
return msl
|
157
|
+
endfunction
|
158
|
+
|
159
|
+
" Check if line 'lnum' has more opening brackets than closing ones.
|
160
|
+
function s:LineHasOpeningBrackets(lnum)
|
161
|
+
let open_0 = 0
|
162
|
+
let open_2 = 0
|
163
|
+
let open_4 = 0
|
164
|
+
let line = getline(a:lnum)
|
165
|
+
let pos = match(line, '[][(){}]', 0)
|
166
|
+
while pos != -1
|
167
|
+
if !s:IsInStringOrComment(a:lnum, pos + 1)
|
168
|
+
let idx = stridx('(){}[]', line[pos])
|
169
|
+
if idx % 2 == 0
|
170
|
+
let open_{idx} = open_{idx} + 1
|
171
|
+
else
|
172
|
+
let open_{idx - 1} = open_{idx - 1} - 1
|
173
|
+
endif
|
174
|
+
endif
|
175
|
+
let pos = match(line, '[][(){}]', pos + 1)
|
176
|
+
endwhile
|
177
|
+
return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
|
178
|
+
endfunction
|
179
|
+
|
180
|
+
function s:Match(lnum, regex)
|
181
|
+
let col = match(getline(a:lnum), a:regex) + 1
|
182
|
+
return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0
|
183
|
+
endfunction
|
184
|
+
|
185
|
+
function s:MatchLast(lnum, regex)
|
186
|
+
let line = getline(a:lnum)
|
187
|
+
let col = match(line, '.*\zs' . a:regex)
|
188
|
+
while col != -1 && s:IsInStringOrComment(a:lnum, col)
|
189
|
+
let line = strpart(line, 0, col)
|
190
|
+
let col = match(line, '.*' . a:regex)
|
191
|
+
endwhile
|
192
|
+
return col + 1
|
193
|
+
endfunction
|
194
|
+
|
195
|
+
" 3. GetRubyIndent Function {{{1
|
196
|
+
" =========================
|
197
|
+
|
198
|
+
function GetRubyIndent()
|
199
|
+
" 3.1. Setup {{{2
|
200
|
+
" ----------
|
201
|
+
|
202
|
+
" Set up variables for restoring position in file. Could use v:lnum here.
|
203
|
+
let vcol = col('.')
|
204
|
+
|
205
|
+
" 3.2. Work on the current line {{{2
|
206
|
+
" -----------------------------
|
207
|
+
|
208
|
+
" Get the current line.
|
209
|
+
let line = getline(v:lnum)
|
210
|
+
let ind = -1
|
211
|
+
|
212
|
+
" If we got a closing bracket on an empty line, find its match and indent
|
213
|
+
" according to it. For parentheses we indent to its column - 1, for the
|
214
|
+
" others we indent to the containing line's MSL's level. Return -1 if fail.
|
215
|
+
let col = matchend(line, '^\s*[]})]')
|
216
|
+
if col > 0 && !s:IsInStringOrComment(v:lnum, col)
|
217
|
+
call cursor(v:lnum, col)
|
218
|
+
let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2)
|
219
|
+
if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
|
220
|
+
if line[col-1]==')' && col('.') != col('$') - 1
|
221
|
+
let ind = virtcol('.')-1
|
222
|
+
else
|
223
|
+
let ind = indent(s:GetMSL(line('.')))
|
224
|
+
endif
|
225
|
+
endif
|
226
|
+
return ind
|
227
|
+
endif
|
228
|
+
|
229
|
+
" If we have a =begin or =end set indent to first column.
|
230
|
+
if match(line, '^\s*\%(=begin\|=end\)$') != -1
|
231
|
+
return 0
|
232
|
+
endif
|
233
|
+
|
234
|
+
" If we have a deindenting keyword, find its match and indent to its level.
|
235
|
+
" TODO: this is messy
|
236
|
+
if s:Match(v:lnum, s:ruby_deindent_keywords)
|
237
|
+
call cursor(v:lnum, 1)
|
238
|
+
if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
|
239
|
+
\ s:end_skip_expr) > 0
|
240
|
+
let line = getline('.')
|
241
|
+
if strpart(line, 0, col('.') - 1) =~ '=\s*$' &&
|
242
|
+
\ strpart(line, col('.') - 1, 2) !~ 'do'
|
243
|
+
let ind = virtcol('.') - 1
|
244
|
+
else
|
245
|
+
let ind = indent('.')
|
246
|
+
endif
|
247
|
+
endif
|
248
|
+
return ind
|
249
|
+
endif
|
250
|
+
|
251
|
+
" If we are in a multi-line string or line-comment, don't do anything to it.
|
252
|
+
if s:IsInStringOrDocumentation(v:lnum, matchend(line, '^\s*') + 1)
|
253
|
+
return indent('.')
|
254
|
+
endif
|
255
|
+
|
256
|
+
" 3.3. Work on the previous line. {{{2
|
257
|
+
" -------------------------------
|
258
|
+
|
259
|
+
" Find a non-blank, non-multi-line string line above the current line.
|
260
|
+
let lnum = s:PrevNonBlankNonString(v:lnum - 1)
|
261
|
+
|
262
|
+
" At the start of the file use zero indent.
|
263
|
+
if lnum == 0
|
264
|
+
return 0
|
265
|
+
endif
|
266
|
+
|
267
|
+
" Set up variables for current line.
|
268
|
+
let line = getline(lnum)
|
269
|
+
let ind = indent(lnum)
|
270
|
+
|
271
|
+
" If the previous line ended with a block opening, add a level of indent.
|
272
|
+
if s:Match(lnum, s:block_regex)
|
273
|
+
return indent(s:GetMSL(lnum)) + &sw
|
274
|
+
endif
|
275
|
+
|
276
|
+
" If the previous line contained an opening bracket, and we are still in it,
|
277
|
+
" add indent depending on the bracket type.
|
278
|
+
if line =~ '[[({]'
|
279
|
+
let counts = s:LineHasOpeningBrackets(lnum)
|
280
|
+
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
|
281
|
+
if col('.') + 1 == col('$')
|
282
|
+
return ind + &sw
|
283
|
+
else
|
284
|
+
return virtcol('.')
|
285
|
+
endif
|
286
|
+
elseif counts[1] == '1' || counts[2] == '1'
|
287
|
+
return ind + &sw
|
288
|
+
else
|
289
|
+
call cursor(v:lnum, vcol)
|
290
|
+
end
|
291
|
+
endif
|
292
|
+
|
293
|
+
" If the previous line ended with an "end", match that "end"s beginning's
|
294
|
+
" indent.
|
295
|
+
let col = s:Match(lnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$')
|
296
|
+
if col > 0
|
297
|
+
call cursor(lnum, col)
|
298
|
+
if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW',
|
299
|
+
\ s:end_skip_expr) > 0
|
300
|
+
let n = line('.')
|
301
|
+
let ind = indent('.')
|
302
|
+
let msl = s:GetMSL(n)
|
303
|
+
if msl != n
|
304
|
+
let ind = indent(msl)
|
305
|
+
end
|
306
|
+
return ind
|
307
|
+
endif
|
308
|
+
end
|
309
|
+
|
310
|
+
let col = s:Match(lnum, s:ruby_indent_keywords)
|
311
|
+
if col > 0
|
312
|
+
call cursor(lnum, col)
|
313
|
+
let ind = virtcol('.') - 1 + &sw
|
314
|
+
" let ind = indent(lnum) + &sw
|
315
|
+
" TODO: make this better (we need to count them) (or, if a searchpair
|
316
|
+
" fails, we know that something is lacking an end and thus we indent a
|
317
|
+
" level
|
318
|
+
if s:Match(lnum, s:end_end_regex)
|
319
|
+
let ind = indent('.')
|
320
|
+
endif
|
321
|
+
return ind
|
322
|
+
endif
|
323
|
+
|
324
|
+
" 3.4. Work on the MSL line. {{{2
|
325
|
+
" --------------------------
|
326
|
+
|
327
|
+
" Set up variables to use and search for MSL to the previous line.
|
328
|
+
let p_lnum = lnum
|
329
|
+
let lnum = s:GetMSL(lnum)
|
330
|
+
|
331
|
+
" If the previous line wasn't a MSL and is continuation return its indent.
|
332
|
+
" TODO: the || s:IsInString() thing worries me a bit.
|
333
|
+
if p_lnum != lnum
|
334
|
+
if s:Match(p_lnum,s:continuation_regex)||s:IsInString(p_lnum,strlen(line))
|
335
|
+
return ind
|
336
|
+
endif
|
337
|
+
endif
|
338
|
+
|
339
|
+
" Set up more variables, now that we know we wasn't continuation bound.
|
340
|
+
let line = getline(lnum)
|
341
|
+
let msl_ind = indent(lnum)
|
342
|
+
|
343
|
+
" If the MSL line had an indenting keyword in it, add a level of indent.
|
344
|
+
" TODO: this does not take into account contrived things such as
|
345
|
+
" module Foo; class Bar; end
|
346
|
+
if s:Match(lnum, s:ruby_indent_keywords)
|
347
|
+
let ind = msl_ind + &sw
|
348
|
+
if s:Match(lnum, s:end_end_regex)
|
349
|
+
let ind = ind - &sw
|
350
|
+
endif
|
351
|
+
return ind
|
352
|
+
endif
|
353
|
+
|
354
|
+
" If the previous line ended with [*+/.-=], indent one extra level.
|
355
|
+
if s:Match(lnum, s:continuation_regex)
|
356
|
+
if lnum == p_lnum
|
357
|
+
let ind = msl_ind + &sw
|
358
|
+
else
|
359
|
+
let ind = msl_ind
|
360
|
+
endif
|
361
|
+
endif
|
362
|
+
|
363
|
+
" }}}2
|
364
|
+
|
365
|
+
return ind
|
366
|
+
endfunction
|
367
|
+
|
368
|
+
" }}}1
|
369
|
+
|
370
|
+
let &cpo = s:cpo_save
|
371
|
+
unlet s:cpo_save
|
372
|
+
|
373
|
+
" vim:set sw=2 sts=2 ts=8 noet ff=unix:
|