File plugin/inccomplete.vim changed (mode: 100644) (index 3e75eeb..c5e465f) |
1 |
1 |
" Name: inccomplete |
" Name: inccomplete |
2 |
2 |
" Author: xaizek <xaizek@openmailbox.org> |
" Author: xaizek <xaizek@openmailbox.org> |
3 |
|
" Version: 1.6.36 |
|
|
3 |
|
" Version: 1.6.40 |
4 |
4 |
" License: Same terms as Vim itself (see :help license) |
" License: Same terms as Vim itself (see :help license) |
5 |
5 |
" |
" |
6 |
6 |
" See :help inccomplete for documentation. |
" See :help inccomplete for documentation. |
|
... |
... |
function! s:ICFilterIncLst(user, inclst, base) |
265 |
265 |
call map(l:inclst, '[substitute(v:val[0], "/", "\\\\", "g"), v:val[1]]') |
call map(l:inclst, '[substitute(v:val[0], "/", "\\\\", "g"), v:val[1]]') |
266 |
266 |
endif |
endif |
267 |
267 |
|
|
|
268 |
|
" handle multicomponent paths (e.g. "a/...", <boost/...>) |
268 |
269 |
if l:pos >= 0 |
if l:pos >= 0 |
269 |
|
" filter by subdirectory name |
|
270 |
|
let l:dirend0 = a:base[:l:pos] |
|
271 |
|
if a:user |
|
272 |
|
let l:dirend1 = fnamemodify(s:ICGetDir().'/'.l:dirend0, ':p') |
|
273 |
|
else |
|
274 |
|
let l:dirend1 = l:dirend0 |
|
275 |
|
endif |
|
276 |
|
if l:sl1 == '/' |
|
277 |
|
let l:dirend2 = substitute(l:dirend1, "\\\\", "/", "g") |
|
278 |
|
else |
|
279 |
|
let l:dirend2 = escape(l:dirend1, '\') |
|
280 |
|
endif |
|
281 |
|
if a:user |
|
282 |
|
call filter(l:inclst, 'v:val[0] =~ "^".l:dirend2."[\\/]*$"') |
|
283 |
|
else |
|
284 |
|
call filter(l:inclst, 'v:val[0] =~ "'.l:sl1.'".l:dirend2."$"') |
|
285 |
|
endif |
|
|
270 |
|
let l:inclst = s:ICFilter(a:user, l:inclst, a:base, s:ICGetDir()) |
|
271 |
|
endif |
286 |
272 |
|
|
287 |
|
" move end of each path to the beginning of filename |
|
288 |
|
let l:cutidx = - (l:pos + 2) |
|
289 |
|
if !empty(l:inclst) && l:inclst[0][0][l:cutidx + 1:] != l:dirend0 |
|
290 |
|
\ && a:user |
|
291 |
|
let l:path = s:ICGetDir() |
|
292 |
|
call map(l:inclst, '[l:path, l:dirend0.v:val[1]]') |
|
293 |
|
else |
|
294 |
|
call map(l:inclst, '[v:val[0][:l:cutidx], l:dirend0.v:val[1]]') |
|
295 |
|
endif |
|
|
273 |
|
return l:inclst |
|
274 |
|
endfunction |
|
275 |
|
|
|
276 |
|
" filters multicomponent paths |
|
277 |
|
function! s:ICFilter(user, inclst, base, dir) |
|
278 |
|
let [l:pos, l:sl1, l:sl2] = s:ICParsePath(a:base) |
|
279 |
|
|
|
280 |
|
let l:inclst = copy(a:inclst) |
|
281 |
|
|
|
282 |
|
" filter by subdirectory name |
|
283 |
|
let l:dirend0 = a:base[:l:pos] |
|
284 |
|
if a:user |
|
285 |
|
let l:dirend1 = fnamemodify(a:dir.'/'.l:dirend0, ':p') |
|
286 |
|
else |
|
287 |
|
let l:dirend1 = l:dirend0 |
|
288 |
|
endif |
|
289 |
|
if l:sl1 == '/' |
|
290 |
|
let l:dirend2 = substitute(l:dirend1, "\\\\", "/", "g") |
|
291 |
|
else |
|
292 |
|
let l:dirend2 = escape(l:dirend1, '\') |
|
293 |
|
endif |
|
294 |
|
if a:user |
|
295 |
|
call filter( |
|
296 |
|
\ l:inclst, |
|
297 |
|
\ 'v:val[0]."/".v:val[1] =~ "^".l:dirend2."\\($\\|[\\/]*.*\\)"') |
|
298 |
|
else |
|
299 |
|
call filter(l:inclst, 'v:val[0] =~ "'.l:sl1.'".l:dirend2."\\?$"') |
|
300 |
|
endif |
|
301 |
|
|
|
302 |
|
" move end of each path to the beginning of filename |
|
303 |
|
let l:cutidx = - (l:pos + 2) |
|
304 |
|
if !empty(l:inclst) && l:inclst[0][0][l:cutidx + 1:] != l:dirend0 |
|
305 |
|
\ && a:user |
|
306 |
|
let l:path = s:ICGetDir() |
|
307 |
|
call map(l:inclst, '[l:path, l:dirend0.v:val[1]]') |
|
308 |
|
else |
|
309 |
|
call map(l:inclst, '[v:val[0][:l:cutidx], l:dirend0.v:val[1]]') |
296 |
310 |
endif |
endif |
297 |
311 |
|
|
298 |
312 |
return l:inclst |
return l:inclst |
|
... |
... |
endfunction |
304 |
318 |
function! s:ICGetList(user, base) |
function! s:ICGetList(user, base) |
305 |
319 |
if a:user |
if a:user |
306 |
320 |
let l:dir = s:ICGetDir() |
let l:dir = s:ICGetDir() |
307 |
|
return s:ICFindIncludes(1, [l:dir] + s:ICGetSubDirs([l:dir], a:base)) |
|
|
321 |
|
let l:dirs = [l:dir] |
|
322 |
|
if exists('b:inccomplete_root') |
|
323 |
|
let l:dirs = [b:inccomplete_root] + l:dirs |
|
324 |
|
endif |
|
325 |
|
let l:dirs += s:ICGetSubDirs(l:dirs, a:base) |
|
326 |
|
return s:ICFindIncludes(1, l:dirs) |
308 |
327 |
endif |
endif |
309 |
328 |
|
|
310 |
329 |
" prepare list of directories |
" prepare list of directories |
|
... |
... |
function! s:ICFindIncludes(user, pathlst) |
391 |
410 |
|
|
392 |
411 |
" prepare a:pathlst by forming regexps |
" prepare a:pathlst by forming regexps |
393 |
412 |
for l:i in range(len(a:pathlst)) |
for l:i in range(len(a:pathlst)) |
|
413 |
|
if a:pathlst[i][-1:] == '/' |
|
414 |
|
let a:pathlst[i] = a:pathlst[i][:-2] |
|
415 |
|
endif |
394 |
416 |
let g:inccomplete_cache[a:pathlst[i]] = [] |
let g:inccomplete_cache[a:pathlst[i]] = [] |
395 |
417 |
let l:tmp = substitute(a:pathlst[i], '\', '/', 'g') |
let l:tmp = substitute(a:pathlst[i], '\', '/', 'g') |
396 |
418 |
let a:pathlst[i] = [a:pathlst[i], '^'.escape(l:tmp, '.')] |
let a:pathlst[i] = [a:pathlst[i], '^'.escape(l:tmp, '.')] |
|
... |
... |
function! s:ICFindIncludes(user, pathlst) |
400 |
422 |
let l:result = [] |
let l:result = [] |
401 |
423 |
for l:file in l:foundlst |
for l:file in l:foundlst |
402 |
424 |
let l:file = substitute(l:file, '\', '/', 'g') |
let l:file = substitute(l:file, '\', '/', 'g') |
|
425 |
|
if l:file[-1:] == '/' |
|
426 |
|
let l:file = l:file[:-2] |
|
427 |
|
endif |
403 |
428 |
" find appropriate parent path ("." at the end forbids exact match) |
" find appropriate parent path ("." at the end forbids exact match) |
404 |
|
let l:pathlst = filter(copy(a:pathlst), 'l:file =~ v:val[1]."."') |
|
|
429 |
|
let l:pathlst = filter(copy(a:pathlst), |
|
430 |
|
\ 'fnamemodify(l:file, ":h") == v:val[0]') |
405 |
431 |
if empty(l:pathlst) |
if empty(l:pathlst) |
406 |
432 |
continue |
continue |
407 |
433 |
endif |
endif |