annotate vendor/vim-packs/ctrlp.vim/autoload/ctrlp/dir.vim @ 719:bcdf320dabf4

Rewrite the ed2k again in php Getting openssl to hash md4 is a pain.
author nanaya <me@nanaya.net>
date Sun, 10 Dec 2023 00:35:22 +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/dir.vim
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
3 " Description: Directory 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_dir') && g:loaded_ctrlp_dir
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_dir, g:ctrlp_newdir] = [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 let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching']
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
14
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
15 cal add(g:ctrlp_ext_vars, {
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
16 \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
17 \ 'accept': 'ctrlp#dir#accept',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
18 \ 'lname': 'dirs',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
19 \ 'sname': 'dir',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
20 \ 'type': 'path',
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
21 \ 'specinput': 1,
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
22 \ })
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:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
25
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
26 let s:dircounts = {}
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
27 " Utilities {{{1
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
28 fu! s:globdirs(dirs, depth)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
29 let entries = split(globpath(a:dirs, s:glob), "\n")
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
30 let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
31 cal extend(g:ctrlp_alldirs, dirs)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
32 let nr = len(g:ctrlp_alldirs)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
33 if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
34 sil! cal ctrlp#progress(nr)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
35 cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
36 cal s:globdirs(join(dirs, ','), depth)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
37 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
38 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
39
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
40 fu! s:max(len, max)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
41 retu a:max && a:len > a:max
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
42 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
43
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
44 fu! s:nocache()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
45 retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching )
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
46 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
47 " Public {{{1
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
48 fu! ctrlp#dir#init(...)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
49 let s:cwd = getcwd()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
50 for each in range(len(s:ars))
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
51 let {s:ars[each]} = a:{each + 1}
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
52 endfo
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
53 let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
54 let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
55 if g:ctrlp_newdir || s:nocache() || !filereadable(cafile)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
56 let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
57 if !ctrlp#igncwd(s:cwd)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
58 cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
59 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
60 cal ctrlp#rmbasedir(g:ctrlp_alldirs)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
61 if len(g:ctrlp_alldirs) <= s:compare_lim
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
62 cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
63 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
64 cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
65 let g:ctrlp_newdir = 0
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
66 el
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
67 if !( exists('s:initcwd') && s:initcwd == s:cwd )
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
68 let s:initcwd = s:cwd
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
69 let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
70 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
71 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
72 cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) })
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
73 retu g:ctrlp_alldirs
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
74 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
75
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
76 fu! ctrlp#dir#accept(mode, str)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
77 let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#call('s:lash', s:cwd).a:str
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
78 if a:mode =~ 't\|v\|h'
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
79 cal ctrlp#exit()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
80 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
81 cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
82 if a:mode == 'e'
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
83 sil! cal ctrlp#statusline()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
84 cal ctrlp#setlines(s:id)
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
85 cal ctrlp#recordhist()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
86 cal ctrlp#prtclear()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
87 en
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
88 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
89
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
90 fu! ctrlp#dir#id()
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
91 retu s:id
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
92 endf
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
93 "}}}
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
94
4576f1471f53 [update-vendor, vim] add ctrlp
nanaya <me@nanaya.net>
parents:
diff changeset
95 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2