|
2 | 2 | " Language: Javascript
|
3 | 3 | " Maintainer: Chris Paul ( https://github.com/bounceme )
|
4 | 4 | " URL: https://github.com/pangloss/vim-javascript
|
5 |
| -" Last Change: September 26, 2016 |
| 5 | +" Last Change: October 8, 2016 |
6 | 6 |
|
7 | 7 | " Only load this indent file when no other was loaded.
|
8 | 8 | if exists('b:did_indent')
|
|
38 | 38 | endif
|
39 | 39 |
|
40 | 40 | let s:line_pre = '^\s*\%(\%(\%(\/\*.\{-}\)\=\*\+\/\s*\)\=\)\@>'
|
| 41 | +let s:line_term = '\s*\%(\%(\/\%(\%(\*.\{-}\*\/\)\|\%(\*\+\)\)\)\s*\)\=$' |
| 42 | + |
41 | 43 | let s:expr_case = '\<\%(\%(case\>\s*\S.\{-}\)\|default\)\s*:\C'
|
42 | 44 | " Regex of syntax group names that are or delimit string or are comments.
|
43 | 45 | let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)'
|
|
64 | 66 | endfunction
|
65 | 67 | endif
|
66 | 68 |
|
67 |
| -let s:line_term = '\s*\%(\%(\/\%(\%(\*.\{-}\*\/\)\|\%(\*\+\)\)\)\s*\)\=$' |
68 |
| - |
| 69 | +" indent/python.vim |
69 | 70 | function s:Trimline(ln)
|
70 |
| - return substitute(substitute(getline(a:ln),':\@<!\/\/.*','',''), s:line_term,'','') |
| 71 | + let pline = getline(a:ln) |
| 72 | + let min = match(pline,'\/[/*]') + 1 |
| 73 | + if min && synIDattr(synID(a:ln, strlen(pline), 0), 'name') =~? '\%(comment\|doc\)' |
| 74 | + let max = match(pline,'.*\zs\/[/*]') + 1 |
| 75 | + while min < max |
| 76 | + let col = (min + max) / 2 |
| 77 | + if synIDattr(synID(a:ln, col, 0), 'name') =~? '\%(comment\|doc\)' |
| 78 | + let max = col |
| 79 | + else |
| 80 | + let min = match(pline,'\/[/*]',col) + 1 |
| 81 | + endif |
| 82 | + endwhile |
| 83 | + let pline = strpart(pline, 0, min - 1) |
| 84 | + endif |
| 85 | + return substitute(pline,'\s*$','','') |
71 | 86 | endfunction
|
72 | 87 |
|
73 | 88 | " configurable regexes that define continuation lines, not including (, {, or [.
|
@@ -179,7 +194,7 @@ function GetJavascriptIndent()
|
179 | 194 | return 0
|
180 | 195 | endif
|
181 | 196 |
|
182 |
| - let l:line = substitute(l:line,s:line_pre,'','') |
| 197 | + let l:line = substitute(l:line,'^\s*\%(\/\*.\{-}\*\/\s*\)*','','') |
183 | 198 |
|
184 | 199 | if l:line =~# '^' . s:expr_case
|
185 | 200 | let cpo_switch = &cpo
|
|
0 commit comments