1 " =============================================================================
2 " File: autoload/ctrlp/rtscript.vim
3 " Description: Runtime scripts extension
4 " Author: Kien Nguyen <github.com/kien>
5 " =============================================================================
8 if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
11 let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
13 cal add(g:ctrlp_ext_vars, {
14 \ 'init': 'ctrlp#rtscript#init(s:caching)',
15 \ 'accept': 'ctrlp#acceptfile',
16 \ 'lname': 'runtime scripts',
22 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
27 retu g:ctrlp_newrts ||
28 \ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
31 fu! ctrlp#rtscript#init(caching)
32 let [s:caching, s:cwd] = [a:caching, getcwd()]
34 \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
35 sil! cal ctrlp#progress('Indexing...')
36 let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n")
37 cal filter(entries, 'count(entries, v:val) == 1')
38 let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
40 let [entries, results] = g:ctrlp_rtscache[2:3]
43 \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
45 sil! cal ctrlp#progress('Processing...')
47 let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
49 let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
50 cal extend(s:filecounts, { s:cwd : len(results) })
54 fu! ctrlp#rtscript#id()
59 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2