annotate vendor/vim-packs/ctrlp.vim/autoload/ctrlp/rtscript.vim @ 721:19909a0557af

[vim] wrong copypasta
author nanaya <me@nanaya.net>
date Wed, 17 Jan 2024 18:06:03 +0900
parents 4576f1471f53
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
707
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
1 " =============================================================================
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
2 " File: autoload/ctrlp/rtscript.vim
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
3 " Description: Runtime scripts extension
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
4 " Author: Kien Nguyen <github.com/kien>
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
5 " =============================================================================
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
6
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
7 " Init {{{1
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
8 if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
9 fini
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
10 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
11 let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
12
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
13 cal add(g:ctrlp_ext_vars, {
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
14 \ 'init': 'ctrlp#rtscript#init(s:caching)',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
15 \ 'accept': 'ctrlp#acceptfile',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
16 \ 'lname': 'runtime scripts',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
17 \ 'sname': 'rts',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
18 \ 'type': 'path',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
19 \ 'opmul': 1,
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
20 \ })
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
21
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
22 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
23
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
24 let s:filecounts = {}
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
25 " Utilities {{{1
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
26 fu! s:nocache()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
27 retu g:ctrlp_newrts ||
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
28 \ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
29 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
30 " Public {{{1
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
31 fu! ctrlp#rtscript#init(caching)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
32 let [s:caching, s:cwd] = [a:caching, getcwd()]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
33 if s:nocache() ||
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
34 \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
35 sil! cal ctrlp#progress('Indexing...')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
36 let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n")
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
37 cal filter(entries, 'count(entries, v:val) == 1')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
38 let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
39 el
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
40 let [entries, results] = g:ctrlp_rtscache[2:3]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
41 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
42 if s:nocache() ||
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
43 \ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
44 if !exists('echoed')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
45 sil! cal ctrlp#progress('Processing...')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
46 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
47 let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
48 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
49 let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
50 cal extend(s:filecounts, { s:cwd : len(results) })
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
51 retu results
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
52 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
53
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
54 fu! ctrlp#rtscript#id()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
55 retu s:id
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
56 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
57 "}}}
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
58
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
59 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2