utils 0.0.67 → 0.0.68

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/VERSION +1 -1
  2. data/bin/edit +3 -1
  3. data/lib/utils/editor.rb +14 -0
  4. data/lib/utils/version.rb +1 -1
  5. data/utils.gemspec +3 -3
  6. metadata +3 -74
  7. data/lib/utils/config/vim/after/syntax/haml.vim +0 -9
  8. data/lib/utils/config/vim/after/syntax/html.vim +0 -11
  9. data/lib/utils/config/vim/autoload/Align.vim +0 -1029
  10. data/lib/utils/config/vim/autoload/AlignMaps.vim +0 -330
  11. data/lib/utils/config/vim/autoload/ctrlp/bookmarkdir.vim +0 -139
  12. data/lib/utils/config/vim/autoload/ctrlp/buffertag.vim +0 -238
  13. data/lib/utils/config/vim/autoload/ctrlp/changes.vim +0 -96
  14. data/lib/utils/config/vim/autoload/ctrlp/dir.vim +0 -90
  15. data/lib/utils/config/vim/autoload/ctrlp/line.vim +0 -63
  16. data/lib/utils/config/vim/autoload/ctrlp/mixed.vim +0 -83
  17. data/lib/utils/config/vim/autoload/ctrlp/mrufiles.vim +0 -119
  18. data/lib/utils/config/vim/autoload/ctrlp/quickfix.vim +0 -62
  19. data/lib/utils/config/vim/autoload/ctrlp/rtscript.vim +0 -49
  20. data/lib/utils/config/vim/autoload/ctrlp/tag.vim +0 -112
  21. data/lib/utils/config/vim/autoload/ctrlp/undo.vim +0 -154
  22. data/lib/utils/config/vim/autoload/ctrlp/utils.vim +0 -72
  23. data/lib/utils/config/vim/autoload/ctrlp.vim +0 -1772
  24. data/lib/utils/config/vim/autoload/rails.vim +0 -4570
  25. data/lib/utils/config/vim/autoload/rubycomplete.vim +0 -801
  26. data/lib/utils/config/vim/autoload/sqlcomplete.vim +0 -741
  27. data/lib/utils/config/vim/autoload/vimball.vim +0 -750
  28. data/lib/utils/config/vim/colors/flori.vim +0 -116
  29. data/lib/utils/config/vim/compiler/coffee.vim +0 -68
  30. data/lib/utils/config/vim/compiler/eruby.vim +0 -40
  31. data/lib/utils/config/vim/compiler/ruby.vim +0 -67
  32. data/lib/utils/config/vim/compiler/rubyunit.vim +0 -34
  33. data/lib/utils/config/vim/doc/Decho.txt +0 -372
  34. data/lib/utils/config/vim/doc/coffee-script.txt +0 -116
  35. data/lib/utils/config/vim/doc/ctrlp.txt +0 -1113
  36. data/lib/utils/config/vim/doc/fugitive.txt +0 -257
  37. data/lib/utils/config/vim/doc/rails.txt +0 -1022
  38. data/lib/utils/config/vim/doc/xml-plugin.txt +0 -226
  39. data/lib/utils/config/vim/ftdetect/coffee.vim +0 -8
  40. data/lib/utils/config/vim/ftdetect/eco.vim +0 -1
  41. data/lib/utils/config/vim/ftdetect/ragel.vim +0 -2
  42. data/lib/utils/config/vim/ftdetect/ruby.vim +0 -17
  43. data/lib/utils/config/vim/ftdetect/slim.vim +0 -2
  44. data/lib/utils/config/vim/ftplugin/coffee.vim +0 -221
  45. data/lib/utils/config/vim/ftplugin/eruby.vim +0 -100
  46. data/lib/utils/config/vim/ftplugin/ruby.vim +0 -260
  47. data/lib/utils/config/vim/ftplugin/xml.vim +0 -941
  48. data/lib/utils/config/vim/indent/IndentAnything_html.vim +0 -35
  49. data/lib/utils/config/vim/indent/coffee.vim +0 -338
  50. data/lib/utils/config/vim/indent/eruby.vim +0 -77
  51. data/lib/utils/config/vim/indent/javascript.vim +0 -116
  52. data/lib/utils/config/vim/indent/ruby.vim +0 -377
  53. data/lib/utils/config/vim/indent/slim.vim +0 -75
  54. data/lib/utils/config/vim/plugin/AlignMapsPlugin.vim +0 -242
  55. data/lib/utils/config/vim/plugin/AlignPlugin.vim +0 -41
  56. data/lib/utils/config/vim/plugin/Decho.vim +0 -592
  57. data/lib/utils/config/vim/plugin/IndentAnything.vim +0 -675
  58. data/lib/utils/config/vim/plugin/bufexplorer.vim +0 -1144
  59. data/lib/utils/config/vim/plugin/cecutil.vim +0 -508
  60. data/lib/utils/config/vim/plugin/ctrlp.vim +0 -61
  61. data/lib/utils/config/vim/plugin/fugitive.vim +0 -2041
  62. data/lib/utils/config/vim/plugin/lusty-explorer.vim +0 -1509
  63. data/lib/utils/config/vim/plugin/rails.vim +0 -339
  64. data/lib/utils/config/vim/plugin/rubyextra.vim +0 -193
  65. data/lib/utils/config/vim/plugin/surround.vim +0 -628
  66. data/lib/utils/config/vim/plugin/taglist.vim +0 -4546
  67. data/lib/utils/config/vim/plugin/test/IndentAnything/test.js +0 -131
  68. data/lib/utils/config/vim/plugin/vimballPlugin.vim +0 -40
  69. data/lib/utils/config/vim/syntax/Decho.vim +0 -101
  70. data/lib/utils/config/vim/syntax/coffee.vim +0 -217
  71. data/lib/utils/config/vim/syntax/eco.vim +0 -62
  72. data/lib/utils/config/vim/syntax/eruby.vim +0 -73
  73. data/lib/utils/config/vim/syntax/javascript.vim +0 -246
  74. data/lib/utils/config/vim/syntax/ragel.vim +0 -165
  75. data/lib/utils/config/vim/syntax/ruby.vim +0 -367
  76. data/lib/utils/config/vim/syntax/slim.vim +0 -117
  77. data/lib/utils/config/vimrc +0 -540
@@ -1,675 +0,0 @@
1
- "
2
- " Copyright 2006 Tye Zdrojewski
3
- "
4
- " Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
- " use this file except in compliance with the License. You may obtain a copy of
6
- " the License at
7
- "
8
- " http://www.apache.org/licenses/LICENSE-2.0
9
- "
10
- " Unless required by applicable law or agreed to in writing, software distributed
11
- " under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
- " CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
- " specific language governing permissions and limitations under the License.
14
- "
15
- "
16
- "
17
- " Plugin:
18
- "
19
- " Indent Anything
20
- "
21
- " Version: 1.2.2
22
- "
23
- " Description:
24
- "
25
- " This is an indentation script that calculates the indent level based
26
- " on begin/end syntax pairs and line-continuation patterns. It allows one
27
- " to create an indent script without writing any code, taking it's
28
- " instruction from configurable values.
29
- "
30
- " Included with this script is Javascript indentation, an example that
31
- " explains the configurable values.
32
- "
33
- "
34
- " Installation:
35
- "
36
- " Place this file in your home directory under ~/.vim/indent/, or replace
37
- " the system indent/javascript.vim file to affect all users.
38
- "
39
- " Maintainer: Tye Z. <zdro@yahoo.com>
40
- "
41
- " Customization:
42
- "
43
- " The only thing that can really be customized at this point is whether or
44
- " not a line is echoed explaining the indentation result. To turn this on,
45
- " set the following variable like so:
46
- "
47
- " let b:indent_anything_echo = 1
48
- "
49
- "
50
- " History:
51
- "
52
- " 1.2 - made some functions script-local to prevent naming collisions
53
- " - fixed some broken indentation in the middle of a block comment,
54
- " which showed up in Javascript indentation.
55
- "
56
- " 1.2.2 - Fixed a bug causing the line after a single-line block comment to
57
- " always have an indent of '0' (i.e. the line after /* comment */).
58
- " - Added Apache 2 license
59
- "
60
- "
61
-
62
- let s:supportedVimVersion = 700
63
-
64
- if version < s:supportedVimVersion
65
- echoerr "IndentAnything only supported for Vim " . s:supportedVimVersion . " and up."
66
- finish
67
- endif
68
-
69
-
70
- "
71
- " Initialize everything needed by this script. Only set those values that are
72
- " not set already.
73
- "
74
- function! IndentAnythingInit()
75
- let b:IndentAnythingInitialized = 1
76
- " Start with a regular expression that will never match. Matching
77
- " will influence behavior, which the defaults should not do.
78
- let s:nonMatcher = '[x]\&[^x]'
79
- if !exists('b:commentRE')
80
- let b:commentRE = s:nonMatcher
81
- endif
82
- if !exists('b:lineCommentRE')
83
- let b:lineCommentRE = s:nonMatcher
84
- endif
85
- if !exists('b:blockCommentRE')
86
- let b:blockCommentRE = s:nonMatcher
87
- endif
88
- if !exists('b:stringRE')
89
- let b:stringRE = s:nonMatcher
90
- endif
91
- if !exists('b:singleQuoteStringRE')
92
- let b:singleQuoteStringRE = s:nonMatcher
93
- endif
94
- if !exists('b:doubleQuoteStringRE')
95
- let b:doubleQuoteStringRE = s:nonMatcher
96
- endif
97
-
98
- if !exists('b:blockCommentStartRE')
99
- let b:blockCommentStartRE = s:nonMatcher
100
- endif
101
- if !exists('b:blockCommentMiddleRE')
102
- let b:blockCommentMiddleRE = s:nonMatcher
103
- endif
104
- if !exists('b:blockCommentEndRE')
105
- let b:blockCommentEndRE = s:nonMatcher
106
- endif
107
- if !exists('b:blockCommentMiddleExtra')
108
- let b:blockCommentMiddleExtra = 0
109
- endif
110
-
111
- if !exists('b:indentTrios')
112
- let b:indentTrios = []
113
- endif
114
- if !exists('b:lineContList')
115
- let b:lineContList = []
116
- endif
117
-
118
- if !exists('b:contTraversesLineComments')
119
- let b:contTraversesLineComments = 1
120
- endif
121
-
122
- if !exists('b:indent_anything_echo')
123
- let b:indent_anything_echo = 0
124
- endif
125
- endfunction
126
-
127
- function! SynHere()
128
- return synIDattr(synID(line('.'), col('.'), 1), "name")
129
- endfunction
130
- "
131
- " Returns true if the cursor is currently inside a comment or a string
132
- "
133
- function! InCommentOrString()
134
- let syn = synIDattr(synID(line("."), col("."), 1), "name")
135
- if syn =~ b:commentRE || syn =~ b:stringRE
136
- return 1
137
- endif
138
- return 0
139
- endfunction
140
-
141
- "
142
- " Returns true if the given line is a comment line (b:lineCommentRE)
143
- "
144
- function! IsLineComment(linenum)
145
- let cursor = getpos('.')
146
- exec a:linenum
147
- normal ^
148
- let l:iscomment = 0
149
- let l:syn = synIDattr(synID(line('.'), col('.'), 1), "name")
150
- if l:syn =~ b:lineCommentRE " b:commentRE || l:syn =~ b:stringRE
151
- let l:iscomment = 1
152
- endif
153
- call setpos('.', cursor)
154
- return l:iscomment
155
- endfunction
156
-
157
- "
158
- " Returns true if the given line is a comment line (b:lineCommentRE)
159
- "
160
- function! IsComment(linenum)
161
- let cursor = getpos('.')
162
- exec a:linenum
163
- normal ^
164
- let l:iscomment = 0
165
- let l:syn = synIDattr(synID(line('.'), col('.'), 1), "name")
166
- if l:syn =~ b:commentRE " b:commentRE || l:syn =~ b:stringRE
167
- let l:iscomment = 1
168
- endif
169
- call setpos('.', cursor)
170
- return l:iscomment
171
- endfunction
172
-
173
- "
174
- " Returns true if the given line is a comment line (b:lineCommentRE)
175
- "
176
- function! IsBlockComment(linenum)
177
- let cursor = getpos('.')
178
- exec a:linenum
179
- normal ^
180
- let l:iscomment = 0
181
- let l:syn = synIDattr(synID(line('.'), col('.'), 1), "name")
182
- if l:syn =~ b:blockCommentRE " b:commentRE || l:syn =~ b:stringRE
183
- let l:iscomment = 1
184
- endif
185
- call setpos('.', cursor)
186
- return l:iscomment
187
- endfunction
188
-
189
- "
190
- " Get the first line at or on the given line that is not blank and is not a
191
- " comment line.
192
- "
193
- function! GetPrevNonBlankNonComment(begin)
194
- let cursor = getpos('.')
195
-
196
- let l:prevbegin = a:begin
197
- while 1
198
- let l:lnum = prevnonblank(l:prevbegin)
199
- if l:lnum == 0
200
- return 0
201
- endif
202
-
203
- "if IsLineComment(l:lnum)
204
- if IsComment(l:lnum)
205
- let l:prevbegin -= 1
206
- continue
207
- endif
208
-
209
- break
210
- endwhile
211
-
212
- " Restore original cursor location
213
- call setpos('.', cursor)
214
- return l:lnum
215
- endfunction
216
-
217
- "
218
- " This does all the work. Does indentation for:
219
- "
220
- " - All pairs defined in b:indentTrios
221
- " - All line continuations in b:lineContList
222
- " - Block comments
223
- "
224
- function! IndentAnything()
225
-
226
- if !exists('b:IndentAnythingInitialized')
227
- call IndentAnythingInit()
228
- endif
229
-
230
- let adj = 0 " Adjustment
231
-
232
- let g:lastindent = ""
233
- let b:hardindent = -1
234
- let currlnum = v:lnum
235
- let currlnum = line('.')
236
- let currline = getline(currlnum)
237
- let lastline = ''
238
- let prevline = ''
239
-
240
- " Find non-blank lines above the current line.
241
- let lastlnum = prevnonblank(currlnum - 1)
242
- let prevlnum = prevnonblank(lastlnum - 1)
243
- if lastlnum != 0
244
- let lastline = getline(lastlnum)
245
- endif
246
- if prevlnum != 0
247
- let prevline = getline(prevlnum)
248
- endif
249
- if b:contTraversesLineComments
250
- let lastcodelnum = GetPrevNonBlankNonComment(currlnum - 1)
251
- let prevcodelnum = GetPrevNonBlankNonComment(lastcodelnum - 1)
252
- if lastcodelnum !=0
253
- let lastcodeline = getline(lastcodelnum)
254
- endif
255
- endif
256
-
257
- " Start from the first char on the line. Vim doesn't seem to consistently
258
- " place the cursor there before calling the indent routines.
259
- call cursor(0, 1)
260
- call search('\S', 'W')
261
-
262
- let l:cur = getpos('.')
263
-
264
- "
265
- " Call indentation adjustment functions.
266
- "
267
-
268
- "
269
- " Block comments
270
- "
271
- let l:BlockCommentAdj = 0
272
- let l:BlockCommentAdj += s:GetBlockCommentIndent(currlnum, lastlnum)
273
- let adj += l:BlockCommentAdj
274
-
275
- "
276
- " Pairs
277
- "
278
- let b:lastclosed = { 'at' : 0 }
279
- let b:pairadj = 0
280
- if !l:BlockCommentAdj
281
- " If we're not in the middle of a block comment (because we haven't
282
- " made any adjustments for that), then process block indentation.
283
- for trio in b:indentTrios
284
- let b:pairadj += s:GetPairIndent(currline, lastline, lastlnum,
285
- \ trio[0], trio[1], trio[2])
286
- endfor
287
- endif
288
- let adj += b:pairadj
289
-
290
- "
291
- " Line continuations
292
- "
293
- let contadj = 0
294
- let isBlockCommentStart = currline =~ '^\s*' . b:blockCommentStartRE
295
- let isBlockCommentMid = (IsBlockComment(currlnum) && !isBlockCommentStart)
296
- if !isBlockCommentMid
297
- " If the current line is not the middle of a block comment, then
298
- " process line continuations.
299
- for ContRule in b:lineContList
300
- if b:contTraversesLineComments "&& !isBlockCommentStart
301
- let contadj = s:GetContIndent(ContRule, currline, lastcodeline, lastcodelnum, prevcodelnum)
302
- else
303
- let contadj = s:GetContIndent(ContRule, currline, lastline, lastlnum, prevlnum)
304
- endif
305
- " This is for line continuation patterns, of which there can be only
306
- " one per line to indicate continuation
307
- if contadj
308
- break
309
- endif
310
- endfor
311
- let adj += contadj
312
- endif
313
-
314
-
315
- "
316
- " Find the previous indent to which we will add the adjustment
317
- "
318
- let prevind = indent(lastlnum)
319
-
320
- if l:BlockCommentAdj
321
- let g:lastindent .= " indent (prevblockcomment: " . prevind . " at " . lastcodelnum . ") "
322
- elseif contadj && b:contTraversesLineComments
323
- " If we have adjusted for line continuation, then use the indentation
324
- " for the previous code line
325
- let prevind = indent(lastcodelnum)
326
- let g:lastindent .= " indent (prevcode: " . prevind . " at " . lastcodelnum . ") "
327
-
328
- elseif (isBlockCommentStart || !IsBlockComment(currlnum)) && IsBlockComment(lastlnum)
329
- " If this is the first line after a block comment, then add the
330
- " adjustment to the line where the block comment started.
331
- let prevind = s:GetPostBlockCommentIndent(lastlnum)
332
- let g:lastindent .= " indent (prevblock: " . prevind . " at " . lastlnum . ") "
333
-
334
- elseif exists("b:defaultIndentExpr")
335
- let g:lastindent .= " using defaultIndentExpr (" . b:defaultIndentExpr . ") "
336
- exec "let prevind = " . b:defaultIndentExpr
337
- else
338
- " Default to adjusting the previous line's indent.
339
- let g:lastindent .= " indent (prev: " . prevind . " at " . lastlnum . ") "
340
- endif
341
-
342
- " Just in case there is no previous indent.
343
- let prevind = (prevind == -1 ? 0 : prevind)
344
-
345
- if b:indent_anything_echo
346
- echom g:lastindent
347
- endif
348
-
349
- call setpos('.', l:cur)
350
-
351
- return adj + prevind
352
-
353
- endfunction
354
-
355
- "
356
- " Get the adjustment for the second line of a block comment. The second line
357
- " will be aligned under the start of the block, even if it is not at the
358
- " beginning of the line. Extra adjustment (b:blockCommentMiddleExtra) will
359
- " be added.
360
- "
361
- function! s:GetBlockCommentIndent(CurrLNum, LastLNum)
362
- let l:cursor = getpos('.')
363
- let l:adj = 0
364
- if a:LastLNum == searchpair(b:blockCommentStartRE, '', b:blockCommentEndRE, 'bWr')
365
- \ && a:LastLNum > 0
366
- let l:adj = col('.') + b:blockCommentMiddleExtra
367
- normal ^
368
- let l:adj -= col('.')
369
- endif
370
- call setpos('.', l:cursor)
371
- return l:adj
372
- endfunction
373
-
374
- function! s:GetPostBlockCommentIndent(LastLNum)
375
-
376
- let l:cursor = getpos('.')
377
- let l:ind = 0
378
- let l:comment_start_lnum = 0;
379
-
380
- " Find beginning of block comment containing the start of line LastLNum
381
- exec a:LastLNum
382
- normal ^
383
- let l:comment_start_lnum = searchpair(
384
- \ b:blockCommentStartRE, b:blockCommentMiddleRE, b:blockCommentEndRE, 'bWr')
385
-
386
- " Assume that the LastLNum is a block comment. If the comment both
387
- " started and stopped on LastLNum, then searchpair will return 0. In that
388
- " case, we just want to return the indent of LastLNum itself.
389
- if 0 == l:comment_start_lnum
390
- let l:comment_start_lnum = a:LastLNum
391
- endif
392
-
393
- let l:ind = indent(l:comment_start_lnum)
394
-
395
- if 1 || l:ind != 0 && b:indent_anything_echo
396
- let g:lastindent = g:lastindent .
397
- \ "GetPostBlockCommentIndent: " . l:ind
398
- endif
399
-
400
- call setpos('.', l:cursor)
401
-
402
- "return l:ind
403
- return l:ind > 0 ? l:ind : 0
404
-
405
- endfunction
406
-
407
- "
408
- " Get additional indentation based on blocks of code, as defined by the Head
409
- " and Tail patterns.
410
- "
411
- function! s:GetPairIndent(CurrLine, LastLine, LastLNum, Head, Mid, Tail)
412
-
413
- let levels = 0
414
- let adj = 0
415
- let origcol = col(".")
416
- let origline = line(".")
417
-
418
-
419
- "
420
- " How many levels were started on the last line? Search backwards for
421
- " pair starters until we're not on the last nonblank. If the last line
422
- " doesn't contain the pair-starter, then don't bother with searchpair();
423
- " it's a performance bottleneck because (I think) it will always search
424
- " all the way back until it finds a match or can't search any more.
425
- "
426
- "
427
- if a:LastLine =~ a:Head
428
- while 1
429
- "
430
- " Include the limit of the search to be the last line. BIG
431
- " performance booster! That also means we only have to see *if*
432
- " there was a match, and not worry about where it is.
433
- "
434
- "let pairstart = searchpair(a:Head, a:Mid, a:Tail, 'Wb')
435
- "if pairstart == 0 || pairstart != a:LastLNum
436
- let pairstart = searchpair(a:Head, a:Mid, a:Tail, 'Wb', '', a:LastLNum)
437
- if pairstart == 0 "|| pairstart != a:LastLNum
438
- break
439
- endif
440
- let syn = synIDattr(synID(line("."), col("."), 1), "name")
441
- " Also continue on the off chance that we find the match on the
442
- " current line. This shouldn't happen, but the pattern might
443
- " start with whitespace.
444
- if syn =~ b:commentRE || syn =~ b:stringRE || pairstart == origline
445
- continue
446
- endif
447
- let levels += 1
448
- endwhile
449
- endif
450
-
451
- " If we aren't within a level that was started on the last line, then
452
- " check how many levels were closed on the last line.
453
- "
454
- if levels == 0
455
-
456
- " Move to the beginning of the last line
457
- call cursor(a:LastLNum,0)
458
- normal ^
459
-
460
- " If the line starts with an open, The close shouldn't be counted as
461
- " such, because we're looking for closes that didn't start on this
462
- " line.
463
- if a:LastLine =~ '^\s*' . a:Head ||
464
- \ (a:Mid != '' && a:LastLine =~ '^\s*' . a:Mid)
465
- let levels = 1
466
- endif
467
-
468
- "
469
- " Count the closes on the last line (i.e. LastLNum), stopping once
470
- " we've hit comments. If the line doesn't even contain the end of the
471
- " pair, don't bother with searchpair() (same aforementioned
472
- " rationale).
473
- "
474
- if a:LastLine =~ a:Tail
475
- while 1
476
- "
477
- " Include the limit of the search to be the last line. BIG
478
- " performance booster! That also means we only have to see
479
- " *if* there was a match, and not worry about where it is.
480
- "
481
- "let pairend = searchpair(a:Head, a:Mid, a:Tail, 'W')
482
- "if pairend == 0 || a:LastLNum != pairend
483
- "let pairend = searchpair(a:Head, a:Mid, a:Tail, 'W', '', a:LastLNum)
484
- let pairend = searchpair(a:Head, a:Mid, a:Tail, 'W',
485
- \'InCommentOrString()', a:LastLNum)
486
- if pairend == 0 "|| a:LastLNum != pairend
487
-
488
- " STARTS with a:Tail, since we already know the line
489
- " matches it.
490
- if b:lastclosed.at < col('.') && (
491
- \ a:LastLine =~ '^\s*' . a:Tail
492
- \ || (a:Mid != '' && a:LastLine =~ '^\s*' . a:Mid) )
493
- let b:lastclosed = {
494
- \ 'at' : col('.'),
495
- \ 'head' : a:Head,
496
- \ 'mid' : a:Mid,
497
- \ 'tail' : a:Tail }
498
- endif
499
-
500
-
501
- break
502
- endif
503
- " This might not be needed with the expr included in the
504
- " search call.
505
- "let syn = synIDattr(synID(line("."), col("."), 1), "name")
506
- "if syn =~ b:commentRE || syn =~ b:stringRE || syn == ''
507
- " break
508
- "endif
509
- let levels -= 1
510
-
511
- " Track the last close to try to match pairs that start on
512
- " line continuations
513
- if b:lastclosed.at < col('.')
514
- let b:lastclosed = {
515
- \ 'at' : col('.'),
516
- \ 'head' : a:Head,
517
- \ 'mid' : a:Mid,
518
- \ 'tail' : a:Tail }
519
- endif
520
- endwhile
521
- endif
522
- endif
523
-
524
- " This is redundant, as per above
525
- " If the current line starts with a close, count it. It won't effect the
526
- " indentation of the next line because it is the first thing on the line
527
- " and won't be counted as a "close on the last line".
528
- if a:CurrLine =~ '^\s*' . a:Tail
529
- \ || (a:Mid != '' && a:CurrLine =~ '^\s*' . a:Mid)
530
- let levels -= 1
531
- endif
532
-
533
- " Restore original cursor location
534
- call cursor(origline, origcol)
535
-
536
- let adj = &sw*levels
537
- if adj != 0 && b:indent_anything_echo
538
- let g:lastindent = g:lastindent .
539
- \ "GetPairIndent(" . a:Head . "/" . b:lastclosed.at . "):" . adj . " "
540
- endif
541
-
542
- return adj
543
-
544
- endfunction
545
-
546
-
547
- function! s:GetContIndent(Rule, CurrLine, LastLine, LastLNum, PrevLNum)
548
-
549
- let adj = 0
550
- let origcol = col(".")
551
- let origline = line(".")
552
- let lastcont = 0
553
- let prevcont = 0
554
-
555
- let l:lastlnum = a:LastLNum
556
- let l:prevlnum = a:PrevLNum
557
-
558
- let l:preblockstart = -1
559
-
560
- " Get the last matching line number. If the match occurs w/in a comment
561
- " or string, then it's a non-match.
562
- "
563
- "let lastmatchlnum = search(a:Rule.pattern, 'Wb', a:PrevLNum)
564
- let lastmatchlnum = search(a:Rule.pattern, 'Wb', a:LastLNum)
565
- let syn = synIDattr(synID(line("."), col("."), 1), "name")
566
-
567
- "if syn =~ b:commentRE || syn =~ b:stringRE
568
- if syn =~ b:commentRE || syn =~ b:stringRE || b:lastclosed.at > 0
569
- let lastmatchlnum = 0
570
- endif
571
-
572
- " Should be able to just search to the line....
573
- " " Figure out the last and previous continuation status
574
- " if lastmatchlnum && lastmatchlnum == a:LastLNum
575
- " let lastcont = 1
576
- " endif
577
- if lastmatchlnum == a:LastLNum
578
- let lastcont = 1
579
- endif
580
-
581
- " start checking at the start of the block that ended on the prev line
582
- if b:lastclosed.at > 0
583
- call cursor(a:LastLNum, b:lastclosed.at)
584
- " TODO: add 'skip' to skip comments
585
- let l:preblockstart = searchpair(b:lastclosed.head, b:lastclosed.mid, b:lastclosed.tail, 'bW')
586
- let g:lastindent .= ' postpair ("' . b:lastclosed.head . '"): '
587
- \ . l:preblockstart . '/' . col('.') . ' '
588
-
589
- if b:contTraversesLineComments
590
- let l:prevlnum = GetPrevNonBlankNonComment(line('.') - 1)
591
- else
592
- let l:prevlnum = prevnonblank(line('.') - 1)
593
- endif
594
- endif
595
-
596
-
597
- " Get the previous matching line number. If the match occurs w/in a
598
- " comment or string, then it's a non-match. Use the adjusted, local
599
- " prevlnum as the limit of the search, since we don't care about matches
600
- " beyond that.
601
- let prevmatchlnum = search(a:Rule.pattern, 'Wb', l:prevlnum)
602
-
603
-
604
- let syn = synIDattr(synID(line("."), col("."), 1), "name")
605
- " Handle:
606
- " if ()
607
- " if () {
608
- " this_line; // should not be reduced
609
- "if syn =~ b:commentRE || syn =~ b:stringRE
610
- if syn =~ b:commentRE || syn =~ b:stringRE
611
- let prevmatchlnum = 0
612
- endif
613
-
614
- " Should be able to just search to the line....
615
- " if ( lastmatchlnum && lastmatchlnum == a:PrevLNum )
616
- " \ || ( prevmatchlnum && prevmatchlnum == l:prevlnum )
617
- " let prevcont = 1
618
- " endif
619
- "
620
- " If there is a previous line, it is a continued line, and we haven't
621
- " already done a positive adjustment for a pair/block, then reduce.
622
- " Don't undo a positive adjustment for a pair because the previous line
623
- " was a continued line. That will happen after the end of the block.
624
- "if prevmatchlnum == l:prevlnum && b:pairadj <= 0
625
- if l:prevlnum && prevmatchlnum == l:prevlnum && b:pairadj <= 0
626
- let prevcont = 1
627
- endif
628
-
629
- "echom "lastcont: " . lastcont .
630
- " \ ", prevcont: " . prevcont .
631
- " \ ", lastmatchlnum: " . lastmatchlnum .
632
- " \ ", prevmatchlnum: " . prevmatchlnum .
633
- " \ ", lastlnum: " . a:LastLNum .
634
- " \ ", PrevLNum: " . a:PrevLNum
635
- let firstcont = (lastcont && !prevcont)
636
- let firstcont = ((lastcont && !prevcont) || (lastcont && b:pairadj))
637
-
638
- " If we are adjusting the current line for a pair, then don't count this
639
- " line as a post-continuation line. The post continuation line will be
640
- " after the close of said pair.
641
- let postcont = (!lastcont && prevcont)
642
- "let postcont = (!lastcont && prevcont && !b:pairadj )
643
-
644
- let g:lastindent .= 'lastcont (' . lastcont . '), prevcont (' . prevcont . ') '
645
-
646
-
647
- "if firstcont && a:CurrLine !~ '^\s*{'
648
- if firstcont
649
- if has_key(a:Rule, 'ignore') && a:CurrLine =~ a:Rule.ignore
650
- let g:lastindent .= "(ignoring '" . a:Rule.ignore . "') "
651
- else
652
- let adj = adj + &sw
653
- endif
654
- "elseif postcont && a:LastLine !~ '^\s*{' "&& !b:pairadj
655
- elseif postcont
656
- if has_key(a:Rule, 'ignore') && a:LastLine =~ a:Rule.ignore
657
- let g:lastindent .= "(ignoring '" . a:Rule.ignore . "') "
658
- else
659
- let adj = adj - &sw
660
- endif
661
- endif
662
-
663
- call cursor(origline, origcol)
664
-
665
- if adj != 0 && b:indent_anything_echo
666
- let g:lastindent = g:lastindent .
667
- \ "GetContIndent('" . a:Rule.pattern . "'):" . adj . " "
668
- endif
669
- return adj
670
-
671
- endfunction
672
-
673
-
674
-
675
-