2012-01-06 01:22:55 -05:00
|
|
|
" =============================================================================
|
|
|
|
" File: autoload/ctrlp/rtscript.vim
|
2012-01-15 12:42:14 -05:00
|
|
|
" Description: Runtime scripts extension
|
2012-01-06 01:22:55 -05:00
|
|
|
" Author: Kien Nguyen <github.com/kien>
|
|
|
|
" =============================================================================
|
|
|
|
|
|
|
|
" Init {{{1
|
|
|
|
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
|
|
|
|
fini
|
|
|
|
en
|
|
|
|
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
|
|
|
|
|
2012-04-07 07:55:23 -04:00
|
|
|
cal add(g:ctrlp_ext_vars, {
|
2012-06-18 13:12:54 -04:00
|
|
|
\ 'init': 'ctrlp#rtscript#init(s:caching)',
|
2012-01-28 12:29:09 -05:00
|
|
|
\ 'accept': 'ctrlp#acceptfile',
|
2012-01-15 12:42:14 -05:00
|
|
|
\ 'lname': 'runtime scripts',
|
|
|
|
\ 'sname': 'rts',
|
|
|
|
\ 'type': 'path',
|
2012-04-02 11:06:32 -04:00
|
|
|
\ 'opmul': 1,
|
2012-04-07 07:55:23 -04:00
|
|
|
\ })
|
2012-01-06 01:22:55 -05:00
|
|
|
|
|
|
|
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
2012-06-18 13:12:54 -04:00
|
|
|
|
|
|
|
let s:filecounts = {}
|
|
|
|
" Utilities {{{1
|
|
|
|
fu! s:nocache()
|
|
|
|
retu !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
|
|
|
|
endf
|
2012-01-06 01:22:55 -05:00
|
|
|
" Public {{{1
|
2012-06-18 13:12:54 -04:00
|
|
|
fu! ctrlp#rtscript#init(caching)
|
|
|
|
let [s:caching, s:cwd] = [a:caching, getcwd()]
|
|
|
|
if g:ctrlp_newrts || s:nocache()
|
2012-01-28 12:29:09 -05:00
|
|
|
\ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
|
2012-01-15 12:42:14 -05:00
|
|
|
sil! cal ctrlp#progress('Indexing...')
|
2012-01-21 23:48:44 -05:00
|
|
|
let entries = split(globpath(&rtp, '**/*.*'), "\n")
|
2012-02-05 04:13:52 -05:00
|
|
|
cal filter(entries, 'count(entries, v:val) == 1')
|
2012-01-28 12:29:09 -05:00
|
|
|
let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
|
|
|
|
el
|
|
|
|
let [entries, results] = g:ctrlp_rtscache[2:3]
|
2012-01-06 01:22:55 -05:00
|
|
|
en
|
2012-06-18 13:12:54 -04:00
|
|
|
if g:ctrlp_newrts || s:nocache()
|
|
|
|
\ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
|
2012-01-28 12:29:09 -05:00
|
|
|
if !exists('echoed') | sil! cal ctrlp#progress('Processing...') | en
|
|
|
|
let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
|
|
|
|
en
|
2012-06-18 13:12:54 -04:00
|
|
|
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
|
|
|
|
cal extend(s:filecounts, { s:cwd : len(results) })
|
2012-01-28 12:29:09 -05:00
|
|
|
retu results
|
2012-01-06 01:22:55 -05:00
|
|
|
endf
|
|
|
|
|
|
|
|
fu! ctrlp#rtscript#id()
|
|
|
|
retu s:id
|
|
|
|
endf
|
|
|
|
"}}}
|
|
|
|
|
|
|
|
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|