utils 0.0.67 → 0.0.68
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/VERSION +1 -1
- data/bin/edit +3 -1
- data/lib/utils/editor.rb +14 -0
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +3 -3
- metadata +3 -74
- data/lib/utils/config/vim/after/syntax/haml.vim +0 -9
- data/lib/utils/config/vim/after/syntax/html.vim +0 -11
- data/lib/utils/config/vim/autoload/Align.vim +0 -1029
- data/lib/utils/config/vim/autoload/AlignMaps.vim +0 -330
- data/lib/utils/config/vim/autoload/ctrlp/bookmarkdir.vim +0 -139
- data/lib/utils/config/vim/autoload/ctrlp/buffertag.vim +0 -238
- data/lib/utils/config/vim/autoload/ctrlp/changes.vim +0 -96
- data/lib/utils/config/vim/autoload/ctrlp/dir.vim +0 -90
- data/lib/utils/config/vim/autoload/ctrlp/line.vim +0 -63
- data/lib/utils/config/vim/autoload/ctrlp/mixed.vim +0 -83
- data/lib/utils/config/vim/autoload/ctrlp/mrufiles.vim +0 -119
- data/lib/utils/config/vim/autoload/ctrlp/quickfix.vim +0 -62
- data/lib/utils/config/vim/autoload/ctrlp/rtscript.vim +0 -49
- data/lib/utils/config/vim/autoload/ctrlp/tag.vim +0 -112
- data/lib/utils/config/vim/autoload/ctrlp/undo.vim +0 -154
- data/lib/utils/config/vim/autoload/ctrlp/utils.vim +0 -72
- data/lib/utils/config/vim/autoload/ctrlp.vim +0 -1772
- data/lib/utils/config/vim/autoload/rails.vim +0 -4570
- data/lib/utils/config/vim/autoload/rubycomplete.vim +0 -801
- data/lib/utils/config/vim/autoload/sqlcomplete.vim +0 -741
- data/lib/utils/config/vim/autoload/vimball.vim +0 -750
- data/lib/utils/config/vim/colors/flori.vim +0 -116
- data/lib/utils/config/vim/compiler/coffee.vim +0 -68
- data/lib/utils/config/vim/compiler/eruby.vim +0 -40
- data/lib/utils/config/vim/compiler/ruby.vim +0 -67
- data/lib/utils/config/vim/compiler/rubyunit.vim +0 -34
- data/lib/utils/config/vim/doc/Decho.txt +0 -372
- data/lib/utils/config/vim/doc/coffee-script.txt +0 -116
- data/lib/utils/config/vim/doc/ctrlp.txt +0 -1113
- data/lib/utils/config/vim/doc/fugitive.txt +0 -257
- data/lib/utils/config/vim/doc/rails.txt +0 -1022
- data/lib/utils/config/vim/doc/xml-plugin.txt +0 -226
- data/lib/utils/config/vim/ftdetect/coffee.vim +0 -8
- data/lib/utils/config/vim/ftdetect/eco.vim +0 -1
- data/lib/utils/config/vim/ftdetect/ragel.vim +0 -2
- data/lib/utils/config/vim/ftdetect/ruby.vim +0 -17
- data/lib/utils/config/vim/ftdetect/slim.vim +0 -2
- data/lib/utils/config/vim/ftplugin/coffee.vim +0 -221
- data/lib/utils/config/vim/ftplugin/eruby.vim +0 -100
- data/lib/utils/config/vim/ftplugin/ruby.vim +0 -260
- data/lib/utils/config/vim/ftplugin/xml.vim +0 -941
- data/lib/utils/config/vim/indent/IndentAnything_html.vim +0 -35
- data/lib/utils/config/vim/indent/coffee.vim +0 -338
- data/lib/utils/config/vim/indent/eruby.vim +0 -77
- data/lib/utils/config/vim/indent/javascript.vim +0 -116
- data/lib/utils/config/vim/indent/ruby.vim +0 -377
- data/lib/utils/config/vim/indent/slim.vim +0 -75
- data/lib/utils/config/vim/plugin/AlignMapsPlugin.vim +0 -242
- data/lib/utils/config/vim/plugin/AlignPlugin.vim +0 -41
- data/lib/utils/config/vim/plugin/Decho.vim +0 -592
- data/lib/utils/config/vim/plugin/IndentAnything.vim +0 -675
- data/lib/utils/config/vim/plugin/bufexplorer.vim +0 -1144
- data/lib/utils/config/vim/plugin/cecutil.vim +0 -508
- data/lib/utils/config/vim/plugin/ctrlp.vim +0 -61
- data/lib/utils/config/vim/plugin/fugitive.vim +0 -2041
- data/lib/utils/config/vim/plugin/lusty-explorer.vim +0 -1509
- data/lib/utils/config/vim/plugin/rails.vim +0 -339
- data/lib/utils/config/vim/plugin/rubyextra.vim +0 -193
- data/lib/utils/config/vim/plugin/surround.vim +0 -628
- data/lib/utils/config/vim/plugin/taglist.vim +0 -4546
- data/lib/utils/config/vim/plugin/test/IndentAnything/test.js +0 -131
- data/lib/utils/config/vim/plugin/vimballPlugin.vim +0 -40
- data/lib/utils/config/vim/syntax/Decho.vim +0 -101
- data/lib/utils/config/vim/syntax/coffee.vim +0 -217
- data/lib/utils/config/vim/syntax/eco.vim +0 -62
- data/lib/utils/config/vim/syntax/eruby.vim +0 -73
- data/lib/utils/config/vim/syntax/javascript.vim +0 -246
- data/lib/utils/config/vim/syntax/ragel.vim +0 -165
- data/lib/utils/config/vim/syntax/ruby.vim +0 -367
- data/lib/utils/config/vim/syntax/slim.vim +0 -117
- data/lib/utils/config/vimrc +0 -540
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
" Vim indent file
|
|
2
|
-
" Language: Ruby
|
|
3
|
-
" Maintainer: Nikolai Weibull <now at bitwi.se>
|
|
4
|
-
" URL: http://vim-ruby.rubyforge.org
|
|
5
|
-
" Anon CVS: See above site
|
|
6
|
-
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
|
7
|
-
|
|
8
|
-
" 0. Initialization {{{1
|
|
9
|
-
" =================
|
|
10
|
-
|
|
11
|
-
" Only load this indent file when no other was loaded.
|
|
12
|
-
if exists("b:did_indent")
|
|
13
|
-
finish
|
|
14
|
-
endif
|
|
15
|
-
let b:did_indent = 1
|
|
16
|
-
|
|
17
|
-
setlocal nosmartindent
|
|
18
|
-
|
|
19
|
-
" Now, set up our indentation expression and keys that trigger it.
|
|
20
|
-
setlocal indentexpr=GetRubyIndent()
|
|
21
|
-
setlocal indentkeys=0{,0},0),0],!^F,o,O,e
|
|
22
|
-
setlocal indentkeys+==end,=elsif,=when,=ensure,=rescue,==begin,==end
|
|
23
|
-
|
|
24
|
-
" Only define the function once.
|
|
25
|
-
if exists("*GetRubyIndent")
|
|
26
|
-
finish
|
|
27
|
-
endif
|
|
28
|
-
|
|
29
|
-
let s:cpo_save = &cpo
|
|
30
|
-
set cpo&vim
|
|
31
|
-
|
|
32
|
-
" 1. Variables {{{1
|
|
33
|
-
" ============
|
|
34
|
-
|
|
35
|
-
" Regex of syntax group names that are or delimit string or are comments.
|
|
36
|
-
let s:syng_strcom = '\<ruby\%(String\|StringEscape\|ASCIICode' .
|
|
37
|
-
\ '\|Interpolation\|NoInterpolation\|Comment\|Documentation\)\>'
|
|
38
|
-
|
|
39
|
-
" Regex of syntax group names that are strings.
|
|
40
|
-
let s:syng_string =
|
|
41
|
-
\ '\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>'
|
|
42
|
-
|
|
43
|
-
" Regex of syntax group names that are strings or documentation.
|
|
44
|
-
let s:syng_stringdoc =
|
|
45
|
-
\'\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>'
|
|
46
|
-
|
|
47
|
-
" Expression used to check whether we should skip a match with searchpair().
|
|
48
|
-
let s:skip_expr =
|
|
49
|
-
\ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
|
|
50
|
-
|
|
51
|
-
" Regex used for words that, at the start of a line, add a level of indent.
|
|
52
|
-
let s:ruby_indent_keywords = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
|
|
53
|
-
\ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure' .
|
|
54
|
-
\ '\|rescue\)\>' .
|
|
55
|
-
\ '\|\%([*+/,=-]\|<<\|>>\|:\s\)\s*\zs' .
|
|
56
|
-
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>'
|
|
57
|
-
|
|
58
|
-
" Regex used for words that, at the start of a line, remove a level of indent.
|
|
59
|
-
let s:ruby_deindent_keywords =
|
|
60
|
-
\ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\)\>'
|
|
61
|
-
|
|
62
|
-
" Regex that defines the start-match for the 'end' keyword.
|
|
63
|
-
"let s:end_start_regex = '\%(^\|[^.]\)\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\|do\)\>'
|
|
64
|
-
" TODO: the do here should be restricted somewhat (only at end of line)?
|
|
65
|
-
let s:end_start_regex = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
|
|
66
|
-
\ '\|while\|until\|case\|unless\|begin\)\>' .
|
|
67
|
-
\ '\|\%([*+/,=-]\|<<\|>>\|:\s\)\s*\zs' .
|
|
68
|
-
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>' .
|
|
69
|
-
\ '\|\<do\>'
|
|
70
|
-
|
|
71
|
-
" Regex that defines the middle-match for the 'end' keyword.
|
|
72
|
-
let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue\>\|when\|elsif\)\>'
|
|
73
|
-
|
|
74
|
-
" Regex that defines the end-match for the 'end' keyword.
|
|
75
|
-
let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end\>'
|
|
76
|
-
|
|
77
|
-
" Expression used for searchpair() call for finding match for 'end' keyword.
|
|
78
|
-
let s:end_skip_expr = s:skip_expr .
|
|
79
|
-
\ ' || (expand("<cword>") == "do"' .
|
|
80
|
-
\ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\)\\>")'
|
|
81
|
-
|
|
82
|
-
" Regex that defines continuation lines, not including (, {, or [.
|
|
83
|
-
let s:continuation_regex = '\%([\\*+/.,:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
|
84
|
-
|
|
85
|
-
" Regex that defines continuation lines.
|
|
86
|
-
" TODO: this needs to deal with if ...: and so on
|
|
87
|
-
let s:continuation_regex2 =
|
|
88
|
-
\ '\%([\\*+/.,:({[]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
|
|
89
|
-
|
|
90
|
-
" Regex that defines blocks.
|
|
91
|
-
let s:block_regex =
|
|
92
|
-
\ '\%(\<do\>\|{\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=\s*\%(#.*\)\=$'
|
|
93
|
-
|
|
94
|
-
" 2. Auxiliary Functions {{{1
|
|
95
|
-
" ======================
|
|
96
|
-
|
|
97
|
-
" Check if the character at lnum:col is inside a string, comment, or is ascii.
|
|
98
|
-
function s:IsInStringOrComment(lnum, col)
|
|
99
|
-
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom
|
|
100
|
-
endfunction
|
|
101
|
-
|
|
102
|
-
" Check if the character at lnum:col is inside a string.
|
|
103
|
-
function s:IsInString(lnum, col)
|
|
104
|
-
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
|
|
105
|
-
endfunction
|
|
106
|
-
|
|
107
|
-
" Check if the character at lnum:col is inside a string or documentation.
|
|
108
|
-
function s:IsInStringOrDocumentation(lnum, col)
|
|
109
|
-
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc
|
|
110
|
-
endfunction
|
|
111
|
-
|
|
112
|
-
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
|
|
113
|
-
function s:PrevNonBlankNonString(lnum)
|
|
114
|
-
let in_block = 0
|
|
115
|
-
let lnum = prevnonblank(a:lnum)
|
|
116
|
-
while lnum > 0
|
|
117
|
-
" Go in and out of blocks comments as necessary.
|
|
118
|
-
" If the line isn't empty (with opt. comment) or in a string, end search.
|
|
119
|
-
let line = getline(lnum)
|
|
120
|
-
if line =~ '^=begin$'
|
|
121
|
-
if in_block
|
|
122
|
-
let in_block = 0
|
|
123
|
-
else
|
|
124
|
-
break
|
|
125
|
-
endif
|
|
126
|
-
elseif !in_block && line =~ '^=end$'
|
|
127
|
-
let in_block = 1
|
|
128
|
-
elseif !in_block && line !~ '^\s*#.*$' && !(s:IsInStringOrComment(lnum, 1)
|
|
129
|
-
\ && s:IsInStringOrComment(lnum, strlen(line)))
|
|
130
|
-
break
|
|
131
|
-
endif
|
|
132
|
-
let lnum = prevnonblank(lnum - 1)
|
|
133
|
-
endwhile
|
|
134
|
-
return lnum
|
|
135
|
-
endfunction
|
|
136
|
-
|
|
137
|
-
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
|
|
138
|
-
function s:GetMSL(lnum)
|
|
139
|
-
" Start on the line we're at and use its indent.
|
|
140
|
-
let msl = a:lnum
|
|
141
|
-
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
|
|
142
|
-
while lnum > 0
|
|
143
|
-
" If we have a continuation line, or we're in a string, use line as MSL.
|
|
144
|
-
" Otherwise, terminate search as we have found our MSL already.
|
|
145
|
-
let line = getline(lnum)
|
|
146
|
-
let col = match(line, s:continuation_regex2) + 1
|
|
147
|
-
if (col > 0 && !s:IsInStringOrComment(lnum, col))
|
|
148
|
-
\ || s:IsInString(lnum, strlen(line))
|
|
149
|
-
let msl = lnum
|
|
150
|
-
else
|
|
151
|
-
break
|
|
152
|
-
endif
|
|
153
|
-
let lnum = s:PrevNonBlankNonString(lnum - 1)
|
|
154
|
-
endwhile
|
|
155
|
-
return msl
|
|
156
|
-
endfunction
|
|
157
|
-
|
|
158
|
-
" Check if line 'lnum' has more opening brackets than closing ones.
|
|
159
|
-
function s:LineHasOpeningBrackets(lnum)
|
|
160
|
-
let open_0 = 0
|
|
161
|
-
let open_2 = 0
|
|
162
|
-
let open_4 = 0
|
|
163
|
-
let line = getline(a:lnum)
|
|
164
|
-
let pos = match(line, '[][(){}]', 0)
|
|
165
|
-
while pos != -1
|
|
166
|
-
if !s:IsInStringOrComment(a:lnum, pos + 1)
|
|
167
|
-
let idx = stridx('(){}[]', line[pos])
|
|
168
|
-
if idx % 2 == 0
|
|
169
|
-
let open_{idx} = open_{idx} + 1
|
|
170
|
-
else
|
|
171
|
-
let open_{idx - 1} = open_{idx - 1} - 1
|
|
172
|
-
endif
|
|
173
|
-
endif
|
|
174
|
-
let pos = match(line, '[][(){}]', pos + 1)
|
|
175
|
-
endwhile
|
|
176
|
-
return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
|
|
177
|
-
endfunction
|
|
178
|
-
|
|
179
|
-
function s:Match(lnum, regex)
|
|
180
|
-
let col = match(getline(a:lnum), a:regex) + 1
|
|
181
|
-
return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0
|
|
182
|
-
endfunction
|
|
183
|
-
|
|
184
|
-
function s:MatchLast(lnum, regex)
|
|
185
|
-
let line = getline(a:lnum)
|
|
186
|
-
let col = match(line, '.*\zs' . a:regex)
|
|
187
|
-
while col != -1 && s:IsInStringOrComment(a:lnum, col)
|
|
188
|
-
let line = strpart(line, 0, col)
|
|
189
|
-
let col = match(line, '.*' . a:regex)
|
|
190
|
-
endwhile
|
|
191
|
-
return col + 1
|
|
192
|
-
endfunction
|
|
193
|
-
|
|
194
|
-
" 3. GetRubyIndent Function {{{1
|
|
195
|
-
" =========================
|
|
196
|
-
|
|
197
|
-
function GetRubyIndent()
|
|
198
|
-
" 3.1. Setup {{{2
|
|
199
|
-
" ----------
|
|
200
|
-
|
|
201
|
-
" Set up variables for restoring position in file. Could use v:lnum here.
|
|
202
|
-
let vcol = col('.')
|
|
203
|
-
|
|
204
|
-
" 3.2. Work on the current line {{{2
|
|
205
|
-
" -----------------------------
|
|
206
|
-
|
|
207
|
-
" Get the current line.
|
|
208
|
-
let line = getline(v:lnum)
|
|
209
|
-
let ind = -1
|
|
210
|
-
|
|
211
|
-
" If we got a closing bracket on an empty line, find its match and indent
|
|
212
|
-
" according to it. For parentheses we indent to its column - 1, for the
|
|
213
|
-
" others we indent to the containing line's MSL's level. Return -1 if fail.
|
|
214
|
-
let col = matchend(line, '^\s*[]})]')
|
|
215
|
-
if col > 0 && !s:IsInStringOrComment(v:lnum, col)
|
|
216
|
-
call cursor(v:lnum, col)
|
|
217
|
-
let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2)
|
|
218
|
-
if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
|
|
219
|
-
if line[col-1]==')' && col('.') != col('$') - 1
|
|
220
|
-
let ind = virtcol('.')-1
|
|
221
|
-
else
|
|
222
|
-
let ind = indent(s:GetMSL(line('.')))
|
|
223
|
-
endif
|
|
224
|
-
endif
|
|
225
|
-
return ind
|
|
226
|
-
endif
|
|
227
|
-
|
|
228
|
-
" If we have a =begin or =end set indent to first column.
|
|
229
|
-
if match(line, '^\s*\%(=begin\|=end\)$') != -1
|
|
230
|
-
return 0
|
|
231
|
-
endif
|
|
232
|
-
|
|
233
|
-
" If we have a deindenting keyword, find its match and indent to its level.
|
|
234
|
-
" TODO: this is messy
|
|
235
|
-
if s:Match(v:lnum, s:ruby_deindent_keywords)
|
|
236
|
-
call cursor(v:lnum, 1)
|
|
237
|
-
if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
|
|
238
|
-
\ s:end_skip_expr) > 0
|
|
239
|
-
let line = getline('.')
|
|
240
|
-
if strpart(line, 0, col('.') - 1) =~ '=\s*$' &&
|
|
241
|
-
\ strpart(line, col('.') - 1, 2) !~ 'do'
|
|
242
|
-
let ind = virtcol('.') - 1
|
|
243
|
-
else
|
|
244
|
-
let ind = indent('.')
|
|
245
|
-
endif
|
|
246
|
-
endif
|
|
247
|
-
return ind
|
|
248
|
-
endif
|
|
249
|
-
|
|
250
|
-
" If we are in a multi-line string or line-comment, don't do anything to it.
|
|
251
|
-
if s:IsInStringOrDocumentation(v:lnum, matchend(line, '^\s*') + 1)
|
|
252
|
-
return indent('.')
|
|
253
|
-
endif
|
|
254
|
-
|
|
255
|
-
" 3.3. Work on the previous line. {{{2
|
|
256
|
-
" -------------------------------
|
|
257
|
-
|
|
258
|
-
" Find a non-blank, non-multi-line string line above the current line.
|
|
259
|
-
let lnum = s:PrevNonBlankNonString(v:lnum - 1)
|
|
260
|
-
|
|
261
|
-
" If the line is empty and inside a string, use the previous line.
|
|
262
|
-
if line =~ '^\s*$' && lnum != prevnonblank(v:lnum - 1)
|
|
263
|
-
return indent(prevnonblank(v:lnum))
|
|
264
|
-
endif
|
|
265
|
-
|
|
266
|
-
" At the start of the file use zero indent.
|
|
267
|
-
if lnum == 0
|
|
268
|
-
return 0
|
|
269
|
-
endif
|
|
270
|
-
|
|
271
|
-
" Set up variables for current line.
|
|
272
|
-
let line = getline(lnum)
|
|
273
|
-
let ind = indent(lnum)
|
|
274
|
-
|
|
275
|
-
" If the previous line ended with a block opening, add a level of indent.
|
|
276
|
-
if s:Match(lnum, s:block_regex)
|
|
277
|
-
return indent(s:GetMSL(lnum)) + &sw
|
|
278
|
-
endif
|
|
279
|
-
|
|
280
|
-
" If the previous line contained an opening bracket, and we are still in it,
|
|
281
|
-
" add indent depending on the bracket type.
|
|
282
|
-
if line =~ '[[({]'
|
|
283
|
-
let counts = s:LineHasOpeningBrackets(lnum)
|
|
284
|
-
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
|
|
285
|
-
if col('.') + 1 == col('$')
|
|
286
|
-
return ind + &sw
|
|
287
|
-
else
|
|
288
|
-
return virtcol('.')
|
|
289
|
-
endif
|
|
290
|
-
elseif counts[1] == '1' || counts[2] == '1'
|
|
291
|
-
return ind + &sw
|
|
292
|
-
else
|
|
293
|
-
call cursor(v:lnum, vcol)
|
|
294
|
-
end
|
|
295
|
-
endif
|
|
296
|
-
|
|
297
|
-
" If the previous line ended with an "end", match that "end"s beginning's
|
|
298
|
-
" indent.
|
|
299
|
-
let col = s:Match(lnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$')
|
|
300
|
-
if col > 0
|
|
301
|
-
call cursor(lnum, col)
|
|
302
|
-
if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW',
|
|
303
|
-
\ s:end_skip_expr) > 0
|
|
304
|
-
let n = line('.')
|
|
305
|
-
let ind = indent('.')
|
|
306
|
-
let msl = s:GetMSL(n)
|
|
307
|
-
if msl != n
|
|
308
|
-
let ind = indent(msl)
|
|
309
|
-
end
|
|
310
|
-
return ind
|
|
311
|
-
endif
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
let col = s:Match(lnum, s:ruby_indent_keywords)
|
|
315
|
-
if col > 0
|
|
316
|
-
call cursor(lnum, col)
|
|
317
|
-
let ind = virtcol('.') - 1 + &sw
|
|
318
|
-
" let ind = indent(lnum) + &sw
|
|
319
|
-
" TODO: make this better (we need to count them) (or, if a searchpair
|
|
320
|
-
" fails, we know that something is lacking an end and thus we indent a
|
|
321
|
-
" level
|
|
322
|
-
if s:Match(lnum, s:end_end_regex)
|
|
323
|
-
let ind = indent('.')
|
|
324
|
-
endif
|
|
325
|
-
return ind
|
|
326
|
-
endif
|
|
327
|
-
|
|
328
|
-
" 3.4. Work on the MSL line. {{{2
|
|
329
|
-
" --------------------------
|
|
330
|
-
|
|
331
|
-
" Set up variables to use and search for MSL to the previous line.
|
|
332
|
-
let p_lnum = lnum
|
|
333
|
-
let lnum = s:GetMSL(lnum)
|
|
334
|
-
|
|
335
|
-
" If the previous line wasn't a MSL and is continuation return its indent.
|
|
336
|
-
" TODO: the || s:IsInString() thing worries me a bit.
|
|
337
|
-
if p_lnum != lnum
|
|
338
|
-
if s:Match(p_lnum,s:continuation_regex)||s:IsInString(p_lnum,strlen(line))
|
|
339
|
-
return ind
|
|
340
|
-
endif
|
|
341
|
-
endif
|
|
342
|
-
|
|
343
|
-
" Set up more variables, now that we know we wasn't continuation bound.
|
|
344
|
-
let line = getline(lnum)
|
|
345
|
-
let msl_ind = indent(lnum)
|
|
346
|
-
|
|
347
|
-
" If the MSL line had an indenting keyword in it, add a level of indent.
|
|
348
|
-
" TODO: this does not take into account contrived things such as
|
|
349
|
-
" module Foo; class Bar; end
|
|
350
|
-
if s:Match(lnum, s:ruby_indent_keywords)
|
|
351
|
-
let ind = msl_ind + &sw
|
|
352
|
-
if s:Match(lnum, s:end_end_regex)
|
|
353
|
-
let ind = ind - &sw
|
|
354
|
-
endif
|
|
355
|
-
return ind
|
|
356
|
-
endif
|
|
357
|
-
|
|
358
|
-
" If the previous line ended with [*+/.-=], indent one extra level.
|
|
359
|
-
if s:Match(lnum, s:continuation_regex)
|
|
360
|
-
if lnum == p_lnum
|
|
361
|
-
let ind = msl_ind + &sw
|
|
362
|
-
else
|
|
363
|
-
let ind = msl_ind
|
|
364
|
-
endif
|
|
365
|
-
endif
|
|
366
|
-
|
|
367
|
-
" }}}2
|
|
368
|
-
|
|
369
|
-
return ind
|
|
370
|
-
endfunction
|
|
371
|
-
|
|
372
|
-
" }}}1
|
|
373
|
-
|
|
374
|
-
let &cpo = s:cpo_save
|
|
375
|
-
unlet s:cpo_save
|
|
376
|
-
|
|
377
|
-
" vim:set sw=2 sts=2 ts=8 noet:
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
" Vim indent file
|
|
2
|
-
" Language: Slim
|
|
3
|
-
|
|
4
|
-
if exists("b:did_indent")
|
|
5
|
-
finish
|
|
6
|
-
endif
|
|
7
|
-
runtime! indent/ruby.vim
|
|
8
|
-
unlet! b:did_indent
|
|
9
|
-
let b:did_indent = 1
|
|
10
|
-
|
|
11
|
-
setlocal autoindent sw=2 et
|
|
12
|
-
setlocal indentexpr=GetSlimIndent()
|
|
13
|
-
setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when
|
|
14
|
-
|
|
15
|
-
" Only define the function once.
|
|
16
|
-
if exists("*GetSlimIndent")
|
|
17
|
-
finish
|
|
18
|
-
endif
|
|
19
|
-
|
|
20
|
-
let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)'
|
|
21
|
-
let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*'
|
|
22
|
-
|
|
23
|
-
if !exists('g:haml_self_closing_tags')
|
|
24
|
-
let g:haml_self_closing_tags = 'meta|link|img|hr|br'
|
|
25
|
-
endif
|
|
26
|
-
|
|
27
|
-
function! GetSlimIndent()
|
|
28
|
-
let lnum = prevnonblank(v:lnum-1)
|
|
29
|
-
if lnum == 0
|
|
30
|
-
return 0
|
|
31
|
-
endif
|
|
32
|
-
let line = substitute(getline(lnum),'\s\+$','','')
|
|
33
|
-
let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
|
|
34
|
-
let lastcol = strlen(line)
|
|
35
|
-
let line = substitute(line,'^\s\+','','')
|
|
36
|
-
let indent = indent(lnum)
|
|
37
|
-
let cindent = indent(v:lnum)
|
|
38
|
-
if cline =~# '\v^-\s*%(elsif|else|when)>'
|
|
39
|
-
let indent = cindent < indent ? cindent : indent - &sw
|
|
40
|
-
endif
|
|
41
|
-
let increase = indent + &sw
|
|
42
|
-
if indent == indent(lnum)
|
|
43
|
-
let indent = cindent <= indent ? -1 : increase
|
|
44
|
-
endif
|
|
45
|
-
|
|
46
|
-
let group = synIDattr(synID(lnum,lastcol,1),'name')
|
|
47
|
-
|
|
48
|
-
if line =~ '^doctype'
|
|
49
|
-
return indent
|
|
50
|
-
elseif line =~ '^/\%(\[[^]]*\]\)\=$'
|
|
51
|
-
return increase
|
|
52
|
-
elseif line =~ '^[\.#]'
|
|
53
|
-
return increase
|
|
54
|
-
elseif line =~? '^div'
|
|
55
|
-
return increase
|
|
56
|
-
elseif group == 'hamlFilter'
|
|
57
|
-
return increase
|
|
58
|
-
elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)'
|
|
59
|
-
return increase
|
|
60
|
-
elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$'
|
|
61
|
-
return increase
|
|
62
|
-
elseif line == '-#'
|
|
63
|
-
return increase
|
|
64
|
-
elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^\v('.g:haml_self_closing_tags.')>'
|
|
65
|
-
return indent
|
|
66
|
-
elseif group =~? '\v^(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$'
|
|
67
|
-
return increase
|
|
68
|
-
elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter'
|
|
69
|
-
return GetRubyIndent()
|
|
70
|
-
else
|
|
71
|
-
return indent
|
|
72
|
-
endif
|
|
73
|
-
endfunction
|
|
74
|
-
|
|
75
|
-
" vim:set sw=2:
|