utils 0.0.0
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/Rakefile +68 -0
- data/VERSION +1 -0
- data/bin/chroot-exec +12 -0
- data/bin/chroot-libs +18 -0
- data/bin/classify +37 -0
- data/bin/discover +137 -0
- data/bin/edit +74 -0
- data/bin/errf +32 -0
- data/bin/git-empty +8 -0
- data/bin/myex +90 -0
- data/bin/number_files +26 -0
- data/bin/same_files +37 -0
- data/bin/search +205 -0
- data/bin/sedit +3 -0
- data/bin/sshscreen +68 -0
- data/bin/term +21 -0
- data/bin/unquarantine_apps +8 -0
- data/bin/untest +17 -0
- data/bin/utils-install-config +10 -0
- data/bin/vacuum_firefox_sqlite +22 -0
- data/bin/xmp +74 -0
- data/lib/utils.rb +8 -0
- data/lib/utils/config.rb +23 -0
- data/lib/utils/config/gdb/asm +179 -0
- data/lib/utils/config/gdb/ruby +528 -0
- data/lib/utils/config/gdbinit +8 -0
- data/lib/utils/config/irbrc +455 -0
- data/lib/utils/config/rdebugrc +2 -0
- data/lib/utils/config/screenrc +143 -0
- data/lib/utils/config/vim/autoload/Align.vim +1029 -0
- data/lib/utils/config/vim/autoload/AlignMaps.vim +330 -0
- data/lib/utils/config/vim/autoload/rails.vim +4744 -0
- data/lib/utils/config/vim/autoload/rubycomplete.vim +801 -0
- data/lib/utils/config/vim/autoload/sqlcomplete.vim +741 -0
- data/lib/utils/config/vim/autoload/vimball.vim +750 -0
- data/lib/utils/config/vim/colors/flori.vim +113 -0
- data/lib/utils/config/vim/compiler/eruby.vim +40 -0
- data/lib/utils/config/vim/compiler/ruby.vim +67 -0
- data/lib/utils/config/vim/compiler/rubyunit.vim +34 -0
- data/lib/utils/config/vim/ftdetect/ragel.vim +2 -0
- data/lib/utils/config/vim/ftdetect/ruby.vim +17 -0
- data/lib/utils/config/vim/ftplugin/eruby.vim +100 -0
- data/lib/utils/config/vim/ftplugin/ruby.vim +260 -0
- data/lib/utils/config/vim/ftplugin/xml.vim +941 -0
- data/lib/utils/config/vim/indent/IndentAnything_html.vim +35 -0
- data/lib/utils/config/vim/indent/eruby.vim +77 -0
- data/lib/utils/config/vim/indent/javascript.vim +116 -0
- data/lib/utils/config/vim/indent/ruby.vim +377 -0
- data/lib/utils/config/vim/plugin/AlignMapsPlugin.vim +242 -0
- data/lib/utils/config/vim/plugin/AlignPlugin.vim +41 -0
- data/lib/utils/config/vim/plugin/Decho.vim +592 -0
- data/lib/utils/config/vim/plugin/IndentAnything.vim +675 -0
- data/lib/utils/config/vim/plugin/bufexplorer.vim +1144 -0
- data/lib/utils/config/vim/plugin/cecutil.vim +482 -0
- data/lib/utils/config/vim/plugin/fugitive.vim +1703 -0
- data/lib/utils/config/vim/plugin/lusty-explorer.vim +1509 -0
- data/lib/utils/config/vim/plugin/rails.vim +340 -0
- data/lib/utils/config/vim/plugin/rubyextra.vim +193 -0
- data/lib/utils/config/vim/plugin/surround.vim +628 -0
- data/lib/utils/config/vim/plugin/taglist.vim +4546 -0
- data/lib/utils/config/vim/plugin/test/IndentAnything/test.js +131 -0
- data/lib/utils/config/vim/plugin/vimballPlugin.vim +40 -0
- data/lib/utils/config/vim/syntax/Decho.vim +101 -0
- data/lib/utils/config/vim/syntax/eruby.vim +73 -0
- data/lib/utils/config/vim/syntax/javascript.vim +246 -0
- data/lib/utils/config/vim/syntax/ragel.vim +165 -0
- data/lib/utils/config/vim/syntax/ruby.vim +367 -0
- data/lib/utils/config/vimrc +461 -0
- data/lib/utils/file.rb +49 -0
- data/lib/utils/find.rb +54 -0
- data/lib/utils/md5.rb +23 -0
- data/lib/utils/patterns.rb +34 -0
- data/lib/utils/version.rb +8 -0
- data/utils.gemspec +33 -0
- metadata +183 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
" Vim color file based on desert.vim
|
2
|
+
|
3
|
+
" cool help screens
|
4
|
+
" :he group-name
|
5
|
+
" :he highlight-groups
|
6
|
+
|
7
|
+
if has("gui_running")
|
8
|
+
set background=dark
|
9
|
+
endif
|
10
|
+
if exists("syntax_on")
|
11
|
+
syntax reset
|
12
|
+
endif
|
13
|
+
if version > 580
|
14
|
+
" no gearantees for version 5.8 and below, but this makes it stop
|
15
|
+
" complaining
|
16
|
+
hi clear
|
17
|
+
if exists("syntax_on")
|
18
|
+
syntax reset
|
19
|
+
endif
|
20
|
+
endif
|
21
|
+
let g:colors_name="flori"
|
22
|
+
|
23
|
+
" general highlight groups
|
24
|
+
hi Normal guifg=lightyellow guibg=grey20
|
25
|
+
hi Cursor guibg=khaki guifg=slategrey
|
26
|
+
hi CursorIM guibg=khaki guifg=slategrey
|
27
|
+
hi CursorColumn guibg=grey25
|
28
|
+
hi CursorLine guibg=grey25
|
29
|
+
hi Folded guibg=grey30 guifg=gold
|
30
|
+
hi FoldColumn guibg=grey30 guifg=tan
|
31
|
+
hi IncSearch guifg=slategrey guibg=khaki
|
32
|
+
hi ModeMsg guifg=goldenrod
|
33
|
+
hi MoreMsg guifg=seagreen
|
34
|
+
hi NonText guifg=lightblue guibg=grey30
|
35
|
+
hi Question guifg=springgreen
|
36
|
+
hi Search guibg=peru guifg=white
|
37
|
+
hi SpecialKey guifg=yellowgreen
|
38
|
+
hi VertSplit guibg=#c2bfa5 guifg=grey50 gui=none
|
39
|
+
hi StatusLine guibg=#c2bfa5 guifg=black gui=none
|
40
|
+
hi StatusLineNC guibg=#c2bfa5 guifg=grey40 gui=none
|
41
|
+
hi Title guifg=indianred
|
42
|
+
hi Visual guifg=NONE guibg=peru
|
43
|
+
hi VisualNOS guifg=NONE guibg=grey25 gui=none
|
44
|
+
hi WarningMsg guifg=salmon guibg=NONE
|
45
|
+
hi LineNr guifg=slategrey guibg=NONE
|
46
|
+
hi Pmenu guifg=grey40 guibg=#c2bfa5 gui=NONE
|
47
|
+
hi PmenuSel guifg=white guibg=grey40 gui=NONE
|
48
|
+
hi PmenuSbar guifg=black guibg=grey30
|
49
|
+
hi PmenuThumb guifg=black guibg=white
|
50
|
+
|
51
|
+
" syntax highlighting groups
|
52
|
+
hi Comment guifg=slategrey guibg=NONE
|
53
|
+
"
|
54
|
+
hi Constant guifg=lightgreen guibg=NONE
|
55
|
+
hi String guifg=salmon guibg=NONE
|
56
|
+
hi Character guifg=greenyellow guibg=NONE
|
57
|
+
hi Number guifg=red guibg=NONE
|
58
|
+
hi Boolean guifg=red guibg=NONE
|
59
|
+
hi link Float Number
|
60
|
+
hi Regexp guifg=tomato guibg=NONE
|
61
|
+
"
|
62
|
+
hi Identifier guifg=palegreen guibg=NONE
|
63
|
+
hi Function guifg=limegreen guibg=NONE
|
64
|
+
"
|
65
|
+
hi Statement guifg=khaki guibg=NONE
|
66
|
+
hi Keyword guifg=brown gui=bold guibg=NONE
|
67
|
+
hi Operator guifg=orangered guibg=NONE
|
68
|
+
"
|
69
|
+
hi PreProc guifg=indianred guibg=NONE
|
70
|
+
"
|
71
|
+
hi Type guifg=darkkhaki guibg=NONE
|
72
|
+
"
|
73
|
+
hi Special guifg=orange guibg=NONE
|
74
|
+
"
|
75
|
+
hi Underlined guifg=darkslateblue gui=underline guibg=NONE
|
76
|
+
"
|
77
|
+
hi Ignore guifg=grey40 guibg=NONE
|
78
|
+
"
|
79
|
+
hi Error guifg=yellow guibg=orangered
|
80
|
+
"
|
81
|
+
hi Todo guifg=orangered guibg=yellow
|
82
|
+
"
|
83
|
+
|
84
|
+
hi rubyInterpolation guifg=moccasin guibg=NONE
|
85
|
+
hi rubyInstanceVariable guifg=orangered guibg=NONE
|
86
|
+
hi rubyClassVariable guifg=#dc1436 guibg=NONE
|
87
|
+
hi rubyGlobalVariable guifg=deeppink guibg=NONE
|
88
|
+
hi rubyEval guifg=red guibg=NONE
|
89
|
+
hi rubyBlockParameter guifg=orchid guibg=NONE
|
90
|
+
hi rubyBlockArgument guifg=orchid guibg=NONE
|
91
|
+
hi link rubyEscape Character
|
92
|
+
hi link rubySymbol Function
|
93
|
+
hi link rubyPseudoVariable Special
|
94
|
+
hi link rubyBoolean Boolean
|
95
|
+
hi link rubyPredefinedVariable Special
|
96
|
+
hi link rubyPredefinedConstant Constant
|
97
|
+
hi link rubyConstant Constant
|
98
|
+
hi link railsMethod PreProc
|
99
|
+
hi link rubyDefine Keyword
|
100
|
+
hi link rubyAccess rubyMethod
|
101
|
+
hi link rubyAttribute rubyMethod
|
102
|
+
hi link rubyException rubyMethod
|
103
|
+
hi link rubyInclude Keyword
|
104
|
+
hi link rubyStringDelimiter rubyString
|
105
|
+
hi link rubyRegexp Regexp
|
106
|
+
hi link rubyRegexpDelimiter rubyRegexp
|
107
|
+
hi link javascriptRegexpString Regexp
|
108
|
+
hi link javascriptNumber Number
|
109
|
+
hi link javascriptNull Constant
|
110
|
+
hi DiffAdd guibg=green guifg=white
|
111
|
+
hi DiffChange guibg=blue guifg=white
|
112
|
+
hi DiffText guifg=yellow
|
113
|
+
hi DiffDelete guibg=red guifg=white
|
@@ -0,0 +1,40 @@
|
|
1
|
+
" Vim compiler file
|
2
|
+
" Language: eRuby
|
3
|
+
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
4
|
+
" URL: http://vim-ruby.rubyforge.org
|
5
|
+
" Anon CVS: See above site
|
6
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
7
|
+
|
8
|
+
if exists("current_compiler")
|
9
|
+
finish
|
10
|
+
endif
|
11
|
+
let current_compiler = "eruby"
|
12
|
+
|
13
|
+
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
14
|
+
command -nargs=* CompilerSet setlocal <args>
|
15
|
+
endif
|
16
|
+
|
17
|
+
let s:cpo_save = &cpo
|
18
|
+
set cpo-=C
|
19
|
+
|
20
|
+
if exists("eruby_compiler") && eruby_compiler == "eruby"
|
21
|
+
CompilerSet makeprg=eruby
|
22
|
+
else
|
23
|
+
CompilerSet makeprg=erb
|
24
|
+
endif
|
25
|
+
|
26
|
+
CompilerSet errorformat=
|
27
|
+
\eruby:\ %f:%l:%m,
|
28
|
+
\%+E%f:%l:\ parse\ error,
|
29
|
+
\%W%f:%l:\ warning:\ %m,
|
30
|
+
\%E%f:%l:in\ %*[^:]:\ %m,
|
31
|
+
\%E%f:%l:\ %m,
|
32
|
+
\%-C%\tfrom\ %f:%l:in\ %.%#,
|
33
|
+
\%-Z%\tfrom\ %f:%l,
|
34
|
+
\%-Z%p^,
|
35
|
+
\%-G%.%#
|
36
|
+
|
37
|
+
let &cpo = s:cpo_save
|
38
|
+
unlet s:cpo_save
|
39
|
+
|
40
|
+
" vim: nowrap sw=2 sts=2 ts=8:
|
@@ -0,0 +1,67 @@
|
|
1
|
+
" Vim compiler file
|
2
|
+
" Language: Ruby
|
3
|
+
" Function: Syntax check and/or error reporting
|
4
|
+
" Maintainer: Tim Hammerquist <timh at rubyforge.org>
|
5
|
+
" URL: http://vim-ruby.rubyforge.org
|
6
|
+
" Anon CVS: See above site
|
7
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
8
|
+
" ----------------------------------------------------------------------------
|
9
|
+
"
|
10
|
+
" Changelog:
|
11
|
+
" 0.2: script saves and restores 'cpoptions' value to prevent problems with
|
12
|
+
" line continuations
|
13
|
+
" 0.1: initial release
|
14
|
+
"
|
15
|
+
" Contributors:
|
16
|
+
" Hugh Sasse <hgs@dmu.ac.uk>
|
17
|
+
" Doug Kearns <djkea2@gus.gscit.monash.edu.au>
|
18
|
+
"
|
19
|
+
" Todo:
|
20
|
+
" match error type %m
|
21
|
+
"
|
22
|
+
" Comments:
|
23
|
+
" I know this file isn't perfect. If you have any questions, suggestions,
|
24
|
+
" patches, etc., please don't hesitate to let me know.
|
25
|
+
"
|
26
|
+
" This is my first experience with 'errorformat' and compiler plugins and
|
27
|
+
" I welcome any input from more experienced (or clearer-thinking)
|
28
|
+
" individuals.
|
29
|
+
" ----------------------------------------------------------------------------
|
30
|
+
|
31
|
+
if exists("current_compiler")
|
32
|
+
finish
|
33
|
+
endif
|
34
|
+
let current_compiler = "ruby"
|
35
|
+
|
36
|
+
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
37
|
+
command -nargs=* CompilerSet setlocal <args>
|
38
|
+
endif
|
39
|
+
|
40
|
+
let s:cpo_save = &cpo
|
41
|
+
set cpo-=C
|
42
|
+
|
43
|
+
" default settings runs script normally
|
44
|
+
" add '-c' switch to run syntax check only:
|
45
|
+
"
|
46
|
+
" CompilerSet makeprg=ruby\ -wc\ $*
|
47
|
+
"
|
48
|
+
" or add '-c' at :make command line:
|
49
|
+
"
|
50
|
+
" :make -c %<CR>
|
51
|
+
"
|
52
|
+
CompilerSet makeprg=ruby\ -w\ $*
|
53
|
+
|
54
|
+
CompilerSet errorformat=
|
55
|
+
\%+E%f:%l:\ parse\ error,
|
56
|
+
\%W%f:%l:\ warning:\ %m,
|
57
|
+
\%E%f:%l:in\ %*[^:]:\ %m,
|
58
|
+
\%E%f:%l:\ %m,
|
59
|
+
\%-C%\tfrom\ %f:%l:in\ %.%#,
|
60
|
+
\%-Z%\tfrom\ %f:%l,
|
61
|
+
\%-Z%p^,
|
62
|
+
\%-G%.%#
|
63
|
+
|
64
|
+
let &cpo = s:cpo_save
|
65
|
+
unlet s:cpo_save
|
66
|
+
|
67
|
+
" vim: nowrap sw=2 sts=2 ts=8:
|
@@ -0,0 +1,34 @@
|
|
1
|
+
" Vim compiler file
|
2
|
+
" Language: Test::Unit - Ruby Unit Testing Framework
|
3
|
+
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
4
|
+
" URL: http://vim-ruby.rubyforge.org
|
5
|
+
" Anon CVS: See above site
|
6
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
7
|
+
|
8
|
+
"if exists("current_compiler")
|
9
|
+
" finish
|
10
|
+
"endif
|
11
|
+
"let current_compiler = "rubyunit"
|
12
|
+
"
|
13
|
+
"if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
14
|
+
" command -nargs=* CompilerSet setlocal <args>
|
15
|
+
"endif
|
16
|
+
"
|
17
|
+
"let s:cpo_save = &cpo
|
18
|
+
"set cpo-=C
|
19
|
+
"
|
20
|
+
"CompilerSet makeprg=testrb
|
21
|
+
"
|
22
|
+
"CompilerSet errorformat=\%W\ %\\+%\\d%\\+)\ Failure:,
|
23
|
+
" \%C%m\ [%f:%l]:,
|
24
|
+
" \%E\ %\\+%\\d%\\+)\ Error:,
|
25
|
+
" \%C%m:,
|
26
|
+
" \%C\ \ \ \ %f:%l:%.%#,
|
27
|
+
" \%C%m,
|
28
|
+
" \%Z\ %#,
|
29
|
+
" \%-G%.%#
|
30
|
+
"
|
31
|
+
"let &cpo = s:cpo_save
|
32
|
+
"unlet s:cpo_save
|
33
|
+
|
34
|
+
" vim: nowrap sw=2 sts=2 ts=8:
|
@@ -0,0 +1,17 @@
|
|
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
|
+
" IRB config
|
14
|
+
au BufNewFile,BufRead .irbrc,irbrc set filetype=ruby
|
15
|
+
|
16
|
+
" eRuby
|
17
|
+
au BufNewFile,BufRead *.erb,*.rhtml set filetype=eruby
|
@@ -0,0 +1,100 @@
|
|
1
|
+
" Vim filetype plugin
|
2
|
+
" Language: eRuby
|
3
|
+
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
4
|
+
" URL: http://vim-ruby.rubyforge.org
|
5
|
+
" Anon CVS: See above site
|
6
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
7
|
+
|
8
|
+
" Only do this when not done yet for this buffer
|
9
|
+
if exists("b:did_ftplugin")
|
10
|
+
finish
|
11
|
+
endif
|
12
|
+
|
13
|
+
let s:save_cpo = &cpo
|
14
|
+
set cpo-=C
|
15
|
+
|
16
|
+
" Define some defaults in case the included ftplugins don't set them.
|
17
|
+
let s:undo_ftplugin = ""
|
18
|
+
let s:browsefilter = "All Files (*.*)\t*.*\n"
|
19
|
+
let s:match_words = ""
|
20
|
+
|
21
|
+
if !exists("g:eruby_default_subtype")
|
22
|
+
let g:eruby_default_subtype = "html"
|
23
|
+
endif
|
24
|
+
|
25
|
+
if !exists("b:eruby_subtype")
|
26
|
+
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
27
|
+
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
28
|
+
if b:eruby_subtype == ''
|
29
|
+
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\)\+$','',''),'\.\zs\w\+$')
|
30
|
+
endif
|
31
|
+
if b:eruby_subtype == 'rhtml'
|
32
|
+
let b:eruby_subtype = 'html'
|
33
|
+
elseif b:eruby_subtype == 'rb'
|
34
|
+
let b:eruby_subtype = 'ruby'
|
35
|
+
elseif b:eruby_subtype == 'yml'
|
36
|
+
let b:eruby_subtype = 'yaml'
|
37
|
+
elseif b:eruby_subtype == 'js'
|
38
|
+
let b:eruby_subtype = 'javascript'
|
39
|
+
elseif b:eruby_subtype == 'txt'
|
40
|
+
" Conventional; not a real file type
|
41
|
+
let b:eruby_subtype = 'text'
|
42
|
+
elseif b:eruby_subtype == ''
|
43
|
+
let b:eruby_subtype = g:eruby_default_subtype
|
44
|
+
endif
|
45
|
+
endif
|
46
|
+
|
47
|
+
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
48
|
+
exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
|
49
|
+
else
|
50
|
+
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
51
|
+
endif
|
52
|
+
unlet! b:did_ftplugin
|
53
|
+
|
54
|
+
" Override our defaults if these were set by an included ftplugin.
|
55
|
+
if exists("b:undo_ftplugin")
|
56
|
+
let s:undo_ftplugin = b:undo_ftplugin
|
57
|
+
unlet b:undo_ftplugin
|
58
|
+
endif
|
59
|
+
if exists("b:browsefilter")
|
60
|
+
let s:browsefilter = b:browsefilter
|
61
|
+
unlet b:browsefilter
|
62
|
+
endif
|
63
|
+
if exists("b:match_words")
|
64
|
+
let s:match_words = b:match_words
|
65
|
+
unlet b:match_words
|
66
|
+
endif
|
67
|
+
|
68
|
+
runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim
|
69
|
+
let b:did_ftplugin = 1
|
70
|
+
|
71
|
+
" Combine the new set of values with those previously included.
|
72
|
+
if exists("b:undo_ftplugin")
|
73
|
+
let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
|
74
|
+
endif
|
75
|
+
if exists ("b:browsefilter")
|
76
|
+
let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
|
77
|
+
endif
|
78
|
+
if exists("b:match_words")
|
79
|
+
let s:match_words = b:match_words . ',' . s:match_words
|
80
|
+
endif
|
81
|
+
|
82
|
+
" Change the browse dialog on Win32 to show mainly eRuby-related files
|
83
|
+
if has("gui_win32")
|
84
|
+
let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter
|
85
|
+
endif
|
86
|
+
|
87
|
+
" Load the combined list of match_words for matchit.vim
|
88
|
+
if exists("loaded_matchit")
|
89
|
+
let b:match_words = s:match_words
|
90
|
+
endif
|
91
|
+
|
92
|
+
" TODO: comments=
|
93
|
+
setlocal commentstring=<%#%s%>
|
94
|
+
|
95
|
+
let b:undo_ftplugin = "setl cms< "
|
96
|
+
\ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
|
97
|
+
|
98
|
+
let &cpo = s:save_cpo
|
99
|
+
|
100
|
+
" vim: nowrap sw=2 sts=2 ts=8:
|
@@ -0,0 +1,260 @@
|
|
1
|
+
" Vim filetype plugin
|
2
|
+
" Language: Ruby
|
3
|
+
" Maintainer: Gavin Sinclair <gsinclair at gmail.com>
|
4
|
+
" URL: http://vim-ruby.rubyforge.org
|
5
|
+
" Anon CVS: See above site
|
6
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
7
|
+
" ----------------------------------------------------------------------------
|
8
|
+
"
|
9
|
+
" Original matchit support thanks to Ned Konz. See his ftplugin/ruby.vim at
|
10
|
+
" http://bike-nomad.com/vim/ruby.vim.
|
11
|
+
" ----------------------------------------------------------------------------
|
12
|
+
|
13
|
+
" Only do this when not done yet for this buffer
|
14
|
+
if (exists("b:did_ftplugin"))
|
15
|
+
finish
|
16
|
+
endif
|
17
|
+
let b:did_ftplugin = 1
|
18
|
+
|
19
|
+
let s:cpo_save = &cpo
|
20
|
+
set cpo&vim
|
21
|
+
|
22
|
+
if has("gui_running") && !has("gui_win32")
|
23
|
+
setlocal keywordprg=ri\ -T
|
24
|
+
else
|
25
|
+
setlocal keywordprg=ri
|
26
|
+
endif
|
27
|
+
|
28
|
+
" Matchit support
|
29
|
+
if exists("loaded_matchit") && !exists("b:match_words")
|
30
|
+
let b:match_ignorecase = 0
|
31
|
+
|
32
|
+
let b:match_words =
|
33
|
+
\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' .
|
34
|
+
\ ':' .
|
35
|
+
\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
|
36
|
+
\ ':' .
|
37
|
+
\ '\<end\>' .
|
38
|
+
\ ',{:},\[:\],(:)'
|
39
|
+
|
40
|
+
let b:match_skip =
|
41
|
+
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
|
42
|
+
\ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
|
43
|
+
\ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
|
44
|
+
\ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
|
45
|
+
\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
|
46
|
+
\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
|
47
|
+
endif
|
48
|
+
|
49
|
+
setlocal formatoptions-=t formatoptions+=croql
|
50
|
+
|
51
|
+
setlocal include=^\\s*\\<\\(load\\\|\w*require\\)\\>
|
52
|
+
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','')
|
53
|
+
setlocal suffixesadd=.rb
|
54
|
+
|
55
|
+
if exists("&ofu") && has("ruby")
|
56
|
+
setlocal omnifunc=rubycomplete#Complete
|
57
|
+
endif
|
58
|
+
|
59
|
+
" To activate, :set ballooneval
|
60
|
+
if has('balloon_eval') && exists('+balloonexpr')
|
61
|
+
setlocal balloonexpr=RubyBalloonexpr()
|
62
|
+
endif
|
63
|
+
|
64
|
+
|
65
|
+
" TODO:
|
66
|
+
"setlocal define=^\\s*def
|
67
|
+
|
68
|
+
setlocal comments=:#
|
69
|
+
setlocal commentstring=#\ %s
|
70
|
+
|
71
|
+
if !exists("s:rubypath")
|
72
|
+
if has("ruby") && has("win32")
|
73
|
+
ruby VIM::command( 'let s:rubypath = "%s"' % ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,}) )
|
74
|
+
let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
|
75
|
+
elseif executable("ruby")
|
76
|
+
let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
|
77
|
+
if &shellxquote == "'"
|
78
|
+
let s:rubypath = system('ruby -e "' . s:code . '"')
|
79
|
+
else
|
80
|
+
let s:rubypath = system("ruby -e '" . s:code . "'")
|
81
|
+
endif
|
82
|
+
let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
|
83
|
+
else
|
84
|
+
" If we can't call ruby to get its path, just default to using the
|
85
|
+
" current directory and the directory of the current file.
|
86
|
+
let s:rubypath = ".,,"
|
87
|
+
endif
|
88
|
+
endif
|
89
|
+
|
90
|
+
let &l:path = s:rubypath
|
91
|
+
|
92
|
+
if has("gui_win32") && !exists("b:browsefilter")
|
93
|
+
let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
|
94
|
+
\ "All Files (*.*)\t*.*\n"
|
95
|
+
endif
|
96
|
+
|
97
|
+
let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< kp<"
|
98
|
+
\."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
|
99
|
+
\."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
|
100
|
+
\."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
|
101
|
+
|
102
|
+
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
|
103
|
+
|
104
|
+
noremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b')<CR>
|
105
|
+
noremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','')<CR>
|
106
|
+
noremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b')<CR>
|
107
|
+
noremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','')<CR>
|
108
|
+
|
109
|
+
noremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b')<CR>
|
110
|
+
noremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','')<CR>
|
111
|
+
noremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b')<CR>
|
112
|
+
noremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','')<CR>
|
113
|
+
|
114
|
+
let b:undo_ftplugin = b:undo_ftplugin
|
115
|
+
\."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
|
116
|
+
\."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'"
|
117
|
+
|
118
|
+
if maparg("\<C-]>",'n') == ''
|
119
|
+
nnoremap <silent> <buffer> <C-]> :<C-U>exe v:count1."tag <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
120
|
+
nnoremap <silent> <buffer> g<C-]> :<C-U>exe "tjump <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
121
|
+
nnoremap <silent> <buffer> g] :<C-U>exe "tselect <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
122
|
+
nnoremap <silent> <buffer> <C-W>] :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
123
|
+
nnoremap <silent> <buffer> <C-W><C-]> :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
124
|
+
nnoremap <silent> <buffer> <C-W>g<C-]> :<C-U>exe "stjump <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
125
|
+
nnoremap <silent> <buffer> <C-W>g] :<C-U>exe "stselect <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
126
|
+
nnoremap <silent> <buffer> <C-W>} :<C-U>exe "ptag <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
127
|
+
nnoremap <silent> <buffer> <C-W>g} :<C-U>exe "ptjump <C-R>=RubyCursorIdentifier()<CR>"<CR>
|
128
|
+
let b:undo_ftplugin = b:undo_ftplugin
|
129
|
+
\."| sil! exe 'nunmap <buffer> <C-]>'| sil! exe 'nunmap <buffer> g<C-]>'| sil! exe 'nunmap <buffer> g]'"
|
130
|
+
\."| sil! exe 'nunmap <buffer> <C-W>]'| sil! exe 'nunmap <buffer> <C-W><C-]>'"
|
131
|
+
\."| sil! exe 'nunmap <buffer> <C-W>g<C-]>'| sil! exe 'nunmap <buffer> <C-W>g]'"
|
132
|
+
\."| sil! exe 'nunmap <buffer> <C-W>}'| sil! exe 'nunmap <buffer> <C-W>g}'"
|
133
|
+
endif
|
134
|
+
endif
|
135
|
+
|
136
|
+
let &cpo = s:cpo_save
|
137
|
+
unlet s:cpo_save
|
138
|
+
|
139
|
+
if exists("g:did_ruby_ftplugin_functions")
|
140
|
+
finish
|
141
|
+
endif
|
142
|
+
let g:did_ruby_ftplugin_functions = 1
|
143
|
+
|
144
|
+
function! RubyBalloonexpr()
|
145
|
+
if !exists('s:ri_found')
|
146
|
+
let s:ri_found = executable('ri')
|
147
|
+
endif
|
148
|
+
if s:ri_found
|
149
|
+
let line = getline(v:beval_lnum)
|
150
|
+
let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$')
|
151
|
+
let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g')
|
152
|
+
let str = b.a
|
153
|
+
let before = strpart(line,0,v:beval_col-strlen(b))
|
154
|
+
let after = strpart(line,v:beval_col+strlen(a))
|
155
|
+
if str =~ '^\.'
|
156
|
+
let str = substitute(str,'^\.','#','g')
|
157
|
+
if before =~ '\]\s*$'
|
158
|
+
let str = 'Array'.str
|
159
|
+
elseif before =~ '}\s*$'
|
160
|
+
" False positives from blocks here
|
161
|
+
let str = 'Hash'.str
|
162
|
+
elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$'
|
163
|
+
let str = 'String'.str
|
164
|
+
elseif before =~ '\$\d\+\.\d\+\s*$'
|
165
|
+
let str = 'Float'.str
|
166
|
+
elseif before =~ '\$\d\+\s*$'
|
167
|
+
let str = 'Integer'.str
|
168
|
+
elseif before =~ '/\s*$'
|
169
|
+
let str = 'Regexp'.str
|
170
|
+
else
|
171
|
+
let str = substitute(str,'^#','.','')
|
172
|
+
endif
|
173
|
+
endif
|
174
|
+
let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','')
|
175
|
+
let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','')
|
176
|
+
let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','')
|
177
|
+
let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','')
|
178
|
+
let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','')
|
179
|
+
let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','')
|
180
|
+
if str !~ '^\w'
|
181
|
+
return ''
|
182
|
+
endif
|
183
|
+
silent! let res = substitute(system("ri -f simple -T \"".str.'"'),'\n$','','')
|
184
|
+
if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method'
|
185
|
+
return ''
|
186
|
+
endif
|
187
|
+
return res
|
188
|
+
else
|
189
|
+
return ""
|
190
|
+
endif
|
191
|
+
endfunction
|
192
|
+
|
193
|
+
function! s:searchsyn(pattern,syn,flags)
|
194
|
+
norm! m'
|
195
|
+
let i = 0
|
196
|
+
let cnt = v:count ? v:count : 1
|
197
|
+
while i < cnt
|
198
|
+
let i = i + 1
|
199
|
+
let line = line('.')
|
200
|
+
let col = col('.')
|
201
|
+
let pos = search(a:pattern,'W'.a:flags)
|
202
|
+
while pos != 0 && s:synname() !~# a:syn
|
203
|
+
let pos = search(a:pattern,'W'.a:flags)
|
204
|
+
endwhile
|
205
|
+
if pos == 0
|
206
|
+
call cursor(line,col)
|
207
|
+
return
|
208
|
+
endif
|
209
|
+
endwhile
|
210
|
+
endfunction
|
211
|
+
|
212
|
+
function! s:synname()
|
213
|
+
return synIDattr(synID(line('.'),col('.'),0),'name')
|
214
|
+
endfunction
|
215
|
+
|
216
|
+
function! RubyCursorIdentifier()
|
217
|
+
let asciicode = '\%(\w\|[]})\"'."'".']\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)'
|
218
|
+
let number = '\%(\%(\w\|[]})\"'."'".']\s*\)\@<!-\)\=\%(\<[[:digit:]_]\+\%(\.[[:digit:]_]\+\)\=\%([Ee][[:digit:]_]\+\)\=\>\|\<0[xXbBoOdD][[:xdigit:]_]\+\>\)\|'.asciicode
|
219
|
+
let operator = '\%(\[\]\|<<\|<=>\|[!<>]=\=\|===\=\|[!=]\~\|>>\|\*\*\|\.\.\.\=\|=>\|[~^&|*/%+-]\)'
|
220
|
+
let method = '\%(\<[_a-zA-Z]\w*\>\%([?!]\|\s*=>\@!\)\=\)'
|
221
|
+
let global = '$\%([!$&"'."'".'*+,./:;<=>?@\`~]\|-\=\w\+\>\)'
|
222
|
+
let symbolizable = '\%(\%(@@\=\)\w\+\>\|'.global.'\|'.method.'\|'.operator.'\)'
|
223
|
+
let pattern = '\C\s*\%('.number.'\|\%(:\@<!:\)\='.symbolizable.'\)'
|
224
|
+
let [lnum, col] = searchpos(pattern,'bcn',line('.'))
|
225
|
+
let raw = matchstr(getline('.')[col-1 : ],pattern)
|
226
|
+
let stripped = substitute(substitute(raw,'\s\+=$','=',''),'^\s*:\=','','')
|
227
|
+
return stripped == '' ? expand("<cword>") : stripped
|
228
|
+
endfunction
|
229
|
+
|
230
|
+
"
|
231
|
+
" Instructions for enabling "matchit" support:
|
232
|
+
"
|
233
|
+
" 1. Look for the latest "matchit" plugin at
|
234
|
+
"
|
235
|
+
" http://www.vim.org/scripts/script.php?script_id=39
|
236
|
+
"
|
237
|
+
" It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
|
238
|
+
"
|
239
|
+
" 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
|
240
|
+
"
|
241
|
+
" 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
|
242
|
+
"
|
243
|
+
" 4. Ensure this file (ftplugin/ruby.vim) is installed.
|
244
|
+
"
|
245
|
+
" 5. Ensure you have this line in your $HOME/.vimrc:
|
246
|
+
" filetype plugin on
|
247
|
+
"
|
248
|
+
" 6. Restart Vim and create the matchit documentation:
|
249
|
+
"
|
250
|
+
" :helptags ~/.vim/doc
|
251
|
+
"
|
252
|
+
" Now you can do ":help matchit", and you should be able to use "%" on Ruby
|
253
|
+
" keywords. Try ":echo b:match_words" to be sure.
|
254
|
+
"
|
255
|
+
" Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the
|
256
|
+
" locations of plugin directories, etc., as there are several options, and it
|
257
|
+
" differs on Windows. Email gsinclair@soyabean.com.au if you need help.
|
258
|
+
"
|
259
|
+
|
260
|
+
" vim: nowrap sw=2 sts=2 ts=8:
|