mirror of
https://github.com/amix/vimrc
synced 2025-06-16 17:45:00 +08:00
lets try again...
This commit is contained in:
56
sources_non_forked/ctrlp.vim/autoload/ctrlp/rtscript.vim
Normal file
56
sources_non_forked/ctrlp.vim/autoload/ctrlp/rtscript.vim
Normal file
@ -0,0 +1,56 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/rtscript.vim
|
||||
" Description: Runtime scripts extension
|
||||
" 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]
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#rtscript#init(s:caching)',
|
||||
\ 'accept': 'ctrlp#acceptfile',
|
||||
\ 'lname': 'runtime scripts',
|
||||
\ 'sname': 'rts',
|
||||
\ 'type': 'path',
|
||||
\ 'opmul': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
let s:filecounts = {}
|
||||
" Utilities {{{1
|
||||
fu! s:nocache()
|
||||
retu !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#rtscript#init(caching)
|
||||
let [s:caching, s:cwd] = [a:caching, getcwd()]
|
||||
if g:ctrlp_newrts || s:nocache()
|
||||
\ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
|
||||
sil! cal ctrlp#progress('Indexing...')
|
||||
let entries = split(globpath(&rtp, '**/*.*'), "\n")
|
||||
cal filter(entries, 'count(entries, v:val) == 1')
|
||||
let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
|
||||
el
|
||||
let [entries, results] = g:ctrlp_rtscache[2:3]
|
||||
en
|
||||
if g:ctrlp_newrts || s:nocache()
|
||||
\ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
|
||||
if !exists('echoed') | sil! cal ctrlp#progress('Processing...') | en
|
||||
let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
|
||||
en
|
||||
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
|
||||
cal extend(s:filecounts, { s:cwd : len(results) })
|
||||
retu results
|
||||
endf
|
||||
|
||||
fu! ctrlp#rtscript#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
Reference in New Issue
Block a user