File autoload/Preamble.vim changed (mode: 100644) (index 92950b9..7890ef4) |
... |
... |
endfunction |
170 |
170 |
fun! s:Length() |
fun! s:Length() |
171 |
171 |
|
|
172 |
172 |
let line_pos = 1 |
let line_pos = 1 |
173 |
|
let is_blankline = 1 |
|
174 |
173 |
|
|
175 |
174 |
while(line_pos <= s:preamble_max_lines) |
while(line_pos <= s:preamble_max_lines) |
|
175 |
|
let synId = synID(line_pos, 1, 1) |
|
176 |
|
let realSynId = synIDtrans(synId) |
|
177 |
|
let attrName = synIDattr( realSynId, 'name' ) |
|
178 |
|
" skip shebang in python |
|
179 |
|
if attrName == 'PreProc' |
|
180 |
|
let line_pos += 1 |
|
181 |
|
continue |
|
182 |
|
endif |
|
183 |
|
|
|
184 |
|
" skip <?php line in PHP sources |
|
185 |
|
if attrName == 'Delimiter' |
|
186 |
|
let line_pos += 1 |
|
187 |
|
break |
|
188 |
|
endif |
176 |
189 |
|
|
177 |
190 |
" skip blank lines at top of file |
" skip blank lines at top of file |
178 |
|
if is_blankline && getline(line_pos) =~ '\S' |
|
179 |
|
let is_blankline = 0 |
|
|
191 |
|
if getline(line_pos) =~ '\S' |
|
192 |
|
break |
180 |
193 |
endif |
endif |
181 |
194 |
|
|
|
195 |
|
let line_pos += 1 |
|
196 |
|
endwhile |
|
197 |
|
|
|
198 |
|
while(line_pos <= s:preamble_max_lines) |
182 |
199 |
" assume each line of a preamble has a character in col one |
" assume each line of a preamble has a character in col one |
183 |
|
if !is_blankline |
|
184 |
|
let synId = synID(line_pos, 1, 1) |
|
185 |
|
let realSynId = synIDtrans(synId) |
|
186 |
|
let attrName = synIDattr( realSynId, 'name' ) |
|
187 |
|
if attrName != 'Comment' && !s:IsInString(line_pos) |
|
188 |
|
break |
|
189 |
|
endif |
|
|
200 |
|
let synStack = synstack(line_pos, 1) |
|
201 |
|
let synId = empty(synStack) ? 0 : synStack[-1] |
|
202 |
|
let realSynId = synIDtrans(synId) |
|
203 |
|
let attrName = synIDattr( realSynId, 'name' ) |
|
204 |
|
if attrName != 'Comment' && !s:IsInString(line_pos) |
|
205 |
|
break |
190 |
206 |
endif |
endif |
191 |
207 |
|
|
192 |
|
let line_pos = line_pos + 1 |
|
|
208 |
|
let line_pos += 1 |
193 |
209 |
endwhile |
endwhile |
194 |
210 |
|
|
195 |
211 |
return line_pos-1 |
return line_pos-1 |