Option to follow symlinks
* Add an option to disable symlinks filtering. * Simplify a few functions.
This commit is contained in:
parent
dffd8692d8
commit
052b48bff6
@ -2,7 +2,7 @@
|
|||||||
" File: autoload/ctrlp.vim
|
" File: autoload/ctrlp.vim
|
||||||
" Description: Fuzzy file, buffer and MRU file finder.
|
" Description: Fuzzy file, buffer and MRU file finder.
|
||||||
" Author: Kien Nguyen <github.com/kien>
|
" Author: Kien Nguyen <github.com/kien>
|
||||||
" Version: 1.6.0
|
" Version: 1.6.1
|
||||||
" =============================================================================
|
" =============================================================================
|
||||||
|
|
||||||
" Static variables {{{
|
" Static variables {{{
|
||||||
@ -13,6 +13,7 @@ fu! s:opts()
|
|||||||
\ 'g:ctrlp_dont_split': ['s:nosplit', ''],
|
\ 'g:ctrlp_dont_split': ['s:nosplit', ''],
|
||||||
\ 'g:ctrlp_dotfiles': ['s:dotfiles', 1],
|
\ 'g:ctrlp_dotfiles': ['s:dotfiles', 1],
|
||||||
\ 'g:ctrlp_extensions': ['s:extensions', []],
|
\ 'g:ctrlp_extensions': ['s:extensions', []],
|
||||||
|
\ 'g:ctrlp_follow_symlinks': ['s:folsym', 0],
|
||||||
\ 'g:ctrlp_highlight_match': ['s:mathi', [1, 'Identifier']],
|
\ 'g:ctrlp_highlight_match': ['s:mathi', [1, 'Identifier']],
|
||||||
\ 'g:ctrlp_jump_to_buffer': ['s:jmptobuf', 1],
|
\ 'g:ctrlp_jump_to_buffer': ['s:jmptobuf', 1],
|
||||||
\ 'g:ctrlp_match_window_bottom': ['s:mwbottom', 1],
|
\ 'g:ctrlp_match_window_bottom': ['s:mwbottom', 1],
|
||||||
@ -29,9 +30,8 @@ fu! s:opts()
|
|||||||
\ 'g:ctrlp_use_caching': ['s:caching', 1],
|
\ 'g:ctrlp_use_caching': ['s:caching', 1],
|
||||||
\ 'g:ctrlp_working_path_mode': ['s:pathmode', 2],
|
\ 'g:ctrlp_working_path_mode': ['s:pathmode', 2],
|
||||||
\ }
|
\ }
|
||||||
for key in keys(opts)
|
for [ke, va] in items(opts)
|
||||||
let def = string(exists(key) ? eval(key) : opts[key][1])
|
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1]) '| unl!' ke
|
||||||
exe 'let' opts[key][0] '=' def '|' 'unl!' key
|
|
||||||
endfo
|
endfo
|
||||||
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
||||||
if !exists('g:ctrlp_user_command') | let g:ctrlp_user_command = '' | en
|
if !exists('g:ctrlp_user_command') | let g:ctrlp_user_command = '' | en
|
||||||
@ -70,8 +70,8 @@ fu! s:Open()
|
|||||||
let hst = filereadable(s:gethistloc()[1]) ? s:gethistdata() : ['']
|
let hst = filereadable(s:gethistloc()[1]) ? s:gethistdata() : ['']
|
||||||
let s:hstry = empty(hst) || !s:maxhst ? [''] : hst
|
let s:hstry = empty(hst) || !s:maxhst ? [''] : hst
|
||||||
en
|
en
|
||||||
for key in keys(s:glbs)
|
for [ke, va] in items(s:glbs)
|
||||||
sil! exe 'let s:glb_'.key.' = &'.key.' | let &'.key.' = '.string(s:glbs[key])
|
sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va)
|
||||||
endfo
|
endfo
|
||||||
if s:opmul && has('signs')
|
if s:opmul && has('signs')
|
||||||
sign define ctrlpmark text=+> texthl=Search
|
sign define ctrlpmark text=+> texthl=Search
|
||||||
@ -124,7 +124,9 @@ endf
|
|||||||
" * Files() {{{
|
" * Files() {{{
|
||||||
fu! s:GlobPath(dirs, allfiles, depth)
|
fu! s:GlobPath(dirs, allfiles, depth)
|
||||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
let entries = split(globpath(a:dirs, s:glob), "\n")
|
||||||
let entries = filter(entries, 'getftype(v:val) != "link"')
|
if !s:folsym
|
||||||
|
let entries = filter(entries, 'getftype(v:val) != "link"')
|
||||||
|
en
|
||||||
let g:ctrlp_allfiles = filter(copy(entries), '!isdirectory(v:val)')
|
let g:ctrlp_allfiles = filter(copy(entries), '!isdirectory(v:val)')
|
||||||
let ftrfunc = s:dotfiles ? 's:dirfilter(v:val)' : 'isdirectory(v:val)'
|
let ftrfunc = s:dotfiles ? 's:dirfilter(v:val)' : 'isdirectory(v:val)'
|
||||||
let alldirs = filter(entries, ftrfunc)
|
let alldirs = filter(entries, ftrfunc)
|
||||||
@ -545,12 +547,12 @@ fu! s:MapSpecs(...)
|
|||||||
\ 'PrtHistory(-1)',
|
\ 'PrtHistory(-1)',
|
||||||
\ 'PrtHistory(1)',
|
\ 'PrtHistory(1)',
|
||||||
\ ]
|
\ ]
|
||||||
for each in prtunmaps | for kp in prtmaps[each]
|
for ke in prtunmaps | for kp in prtmaps[ke]
|
||||||
exe lcmap kp '<Nop>'
|
exe lcmap kp '<Nop>'
|
||||||
endfo | endfo
|
endfo | endfo
|
||||||
el
|
el
|
||||||
for each in keys(prtmaps) | for kp in prtmaps[each]
|
for [ke, va] in items(prtmaps) | for kp in va
|
||||||
exe lcmap kp ':<c-u>cal <SID>'.each.'<cr>'
|
exe lcmap kp ':<c-u>cal <SID>'.ke.'<cr>'
|
||||||
endfo | endfo
|
endfo | endfo
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
@ -631,15 +633,14 @@ fu! ctrlp#acceptfile(mode, matchstr)
|
|||||||
en
|
en
|
||||||
" Switch to existing buffer or open new one
|
" Switch to existing buffer or open new one
|
||||||
if exists('jmpb') && buftab[0]
|
if exists('jmpb') && buftab[0]
|
||||||
exe 'norm!' buftab[1].'gt'
|
exe 'tabn' buftab[1]
|
||||||
exe buftab[0].'winc w'
|
exe buftab[0].'winc w'
|
||||||
elsei exists('jmpb') && bufwinnr > 0
|
elsei exists('jmpb') && bufwinnr > 0
|
||||||
exe bufwinnr.'winc w'
|
exe bufwinnr.'winc w'
|
||||||
el
|
el
|
||||||
" Determine the command to use
|
" Determine the command to use
|
||||||
if md == 't' || s:splitwin == 1
|
if md == 't' || s:splitwin == 1
|
||||||
tabnew
|
let cmd = 'tabe'
|
||||||
let cmd = 'e'
|
|
||||||
elsei md == 'h' || s:splitwin == 2
|
elsei md == 'h' || s:splitwin == 2
|
||||||
let cmd = 'new'
|
let cmd = 'new'
|
||||||
elsei md == 'v' || s:splitwin == 3
|
elsei md == 'v' || s:splitwin == 3
|
||||||
@ -679,8 +680,7 @@ fu! s:CreateNewFile() "{{{
|
|||||||
cal s:insertcache(str)
|
cal s:insertcache(str)
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
if s:newfop == 1
|
if s:newfop == 1
|
||||||
tabnew
|
let cmd = 'tabe'
|
||||||
let cmd = 'e'
|
|
||||||
elsei s:newfop == 2
|
elsei s:newfop == 2
|
||||||
let cmd = 'new'
|
let cmd = 'new'
|
||||||
elsei s:newfop == 3
|
elsei s:newfop == 3
|
||||||
@ -746,9 +746,9 @@ fu! s:OpenMulti()
|
|||||||
let spt = len(s:opmul) > 1 ? cmds[matchstr(s:opmul, '\w$')] : 'vne'
|
let spt = len(s:opmul) > 1 ? cmds[matchstr(s:opmul, '\w$')] : 'vne'
|
||||||
let nr = matchstr(s:opmul, '^\d\+')
|
let nr = matchstr(s:opmul, '^\d\+')
|
||||||
exe wnr.'winc w'
|
exe wnr.'winc w'
|
||||||
for key in keys(mkd)
|
for [ke, va] in items(mkd)
|
||||||
let cmd = ic == 1 ? 'e' : spt
|
let cmd = ic == 1 ? 'e' : spt
|
||||||
cal s:openfile(cmd, mkd[key])
|
cal s:openfile(cmd, va)
|
||||||
if nr > 1 && nr < ic | clo! | el | let ic += 1 | en
|
if nr > 1 && nr < ic | clo! | el | let ic += 1 | en
|
||||||
endfo
|
endfo
|
||||||
endf
|
endf
|
||||||
@ -807,9 +807,7 @@ fu! s:matchlens(str, pat, ...)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:shortest(lens)
|
fu! s:shortest(lens)
|
||||||
let lns = []
|
retu min(map(values(a:lens), 'v:val[0]'))
|
||||||
for nr in keys(a:lens) | cal add(lns, a:lens[nr][0]) | endfo
|
|
||||||
retu min(lns)
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:wordonly(lens)
|
fu! s:wordonly(lens)
|
||||||
@ -842,9 +840,9 @@ fu! s:statusline(...)
|
|||||||
\ ['buffers', 'buf'],
|
\ ['buffers', 'buf'],
|
||||||
\ ['mru files', 'mru'],
|
\ ['mru files', 'mru'],
|
||||||
\ ]
|
\ ]
|
||||||
if exists('g:ctrlp_ext_vars') | for each in g:ctrlp_ext_vars
|
if exists('g:ctrlp_ext_vars')
|
||||||
cal add(s:statypes, [ each[2], each[3] ])
|
cal map(copy(g:ctrlp_ext_vars), 'add(s:statypes, [ v:val[2], v:val[3] ])')
|
||||||
endfo | en
|
en
|
||||||
en
|
en
|
||||||
let tps = s:statypes
|
let tps = s:statypes
|
||||||
let max = len(tps) - 1
|
let max = len(tps) - 1
|
||||||
@ -1021,11 +1019,7 @@ fu! s:dictindex(dict, expr)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:vacantdict(dict)
|
fu! s:vacantdict(dict)
|
||||||
let vac = []
|
retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)')
|
||||||
for ic in range(1, max(keys(a:dict)))
|
|
||||||
if !has_key(a:dict, ic) | cal add(vac, ic) | en
|
|
||||||
endfo
|
|
||||||
retu vac
|
|
||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
" Buffers {{{
|
" Buffers {{{
|
||||||
@ -1232,22 +1226,21 @@ fu! s:SetLines(type)
|
|||||||
\ 's:Buffers()',
|
\ 's:Buffers()',
|
||||||
\ 'ctrlp#mrufiles#list(-1)',
|
\ 'ctrlp#mrufiles#list(-1)',
|
||||||
\ ]
|
\ ]
|
||||||
if exists('g:ctrlp_ext_vars') | for each in g:ctrlp_ext_vars
|
if exists('g:ctrlp_ext_vars')
|
||||||
cal add(types, each[0])
|
cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val[0])')
|
||||||
endfo | en
|
en
|
||||||
let g:ctrlp_lines = eval(types[a:type])
|
let g:ctrlp_lines = eval(types[a:type])
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#init(type, ...)
|
fu! ctrlp#init(type, ...)
|
||||||
if exists('s:init') | retu | en
|
if exists('s:init') | retu | en
|
||||||
let [s:matches, s:init] = [1, 1]
|
let [s:matches, s:init] = [1, 1]
|
||||||
let input = exists('a:1') ? a:1 : ''
|
|
||||||
cal s:Open()
|
cal s:Open()
|
||||||
cal s:SetWD(input)
|
cal s:SetWD(exists('a:1') ? a:1 : '')
|
||||||
cal s:MapKeys()
|
cal s:MapKeys()
|
||||||
cal s:SetLines(a:type)
|
cal s:SetLines(a:type)
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
cal s:syntax()
|
if has('syntax') && exists('g:syntax_on') | cal s:syntax() | en
|
||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
if has('autocmd') "{{{
|
if has('autocmd') "{{{
|
||||||
|
@ -12,9 +12,8 @@ fu! ctrlp#mrufiles#opts()
|
|||||||
\ 'g:ctrlp_mruf_exclude': ['s:exclude', ''],
|
\ 'g:ctrlp_mruf_exclude': ['s:exclude', ''],
|
||||||
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
|
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
|
||||||
\ }
|
\ }
|
||||||
for key in keys(opts)
|
for [ke, va] in items(opts)
|
||||||
let def = string(exists(key) ? eval(key) : opts[key][1])
|
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1]) '| unl!' ke
|
||||||
exe 'let' opts[key][0] '=' def '|' 'unl!' key
|
|
||||||
endfo
|
endfo
|
||||||
endf
|
endf
|
||||||
cal ctrlp#mrufiles#opts()
|
cal ctrlp#mrufiles#opts()
|
||||||
@ -51,11 +50,7 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{
|
|||||||
cal ctrlp#utils#writecache(mrufs, cadir, cafile)
|
cal ctrlp#utils#writecache(mrufs, cadir, cafile)
|
||||||
endf "}}}
|
endf "}}}
|
||||||
fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
|
fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
|
||||||
for each in range(len(a:mrufs) - 1, 0, -1)
|
cal filter(a:mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
|
||||||
if empty(ctrlp#utils#glob(a:mrufs[each], 1))
|
|
||||||
cal remove(a:mrufs, each)
|
|
||||||
en
|
|
||||||
endfo
|
|
||||||
cal ctrlp#utils#writecache(a:mrufs, a:cadir, a:cafile)
|
cal ctrlp#utils#writecache(a:mrufs, a:cadir, a:cafile)
|
||||||
retu a:mrufs
|
retu a:mrufs
|
||||||
endf "}}}
|
endf "}}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*ctrlp.txt* Fuzzy file, buffer and MRU file finder. v1.6.0
|
*ctrlp.txt* Fuzzy file, buffer and MRU file finder. v1.6.1
|
||||||
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
|
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
# #
|
# #
|
||||||
@ -69,7 +69,7 @@ Set the maximum height of the match window: >
|
|||||||
<
|
<
|
||||||
|
|
||||||
*'g:ctrlp_jump_to_buffer'*
|
*'g:ctrlp_jump_to_buffer'*
|
||||||
Set this to 0 to disable the jump-to-open-buffer feature; set to 2 to also jump
|
Set this to 0 to disable the jump-to-open-buffer feature. Set to 2 to also jump
|
||||||
tab if the selected buffer’s opened in another tab: >
|
tab if the selected buffer’s opened in another tab: >
|
||||||
let g:ctrlp_jump_to_buffer = 1
|
let g:ctrlp_jump_to_buffer = 1
|
||||||
<
|
<
|
||||||
@ -95,8 +95,8 @@ Use this to set your own root markers in addition to the default ones. Your
|
|||||||
markers will take precedence: >
|
markers will take precedence: >
|
||||||
let g:ctrlp_root_markers = ['']
|
let g:ctrlp_root_markers = ['']
|
||||||
<
|
<
|
||||||
These markers (builtins and yours) will serve as identifier for the '/' and '\'
|
These markers (builtins and yours) will serve as identifiers for the '/' and
|
||||||
special inputs (section 5.e)
|
'\' special inputs (section 5.e)
|
||||||
|
|
||||||
*'g:ctrlp_use_caching'*
|
*'g:ctrlp_use_caching'*
|
||||||
Set this to 0 to disable per-session caching. When disabled, caching will still
|
Set this to 0 to disable per-session caching. When disabled, caching will still
|
||||||
@ -233,7 +233,8 @@ faster when working with large projects: >
|
|||||||
let g:ctrlp_user_command = [repo_marker, vcs_ls_command, fallback_command]
|
let g:ctrlp_user_command = [repo_marker, vcs_ls_command, fallback_command]
|
||||||
<
|
<
|
||||||
If the fallback_command is empty or not defined, globpath() will then be used
|
If the fallback_command is empty or not defined, globpath() will then be used
|
||||||
when outside a repo. Examples: >
|
when outside a repo.
|
||||||
|
Examples: >
|
||||||
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
|
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
|
||||||
let g:ctrlp_user_command = ['.hg/', 'hg --cwd %s locate --fullpath -I .']
|
let g:ctrlp_user_command = ['.hg/', 'hg --cwd %s locate --fullpath -I .']
|
||||||
<
|
<
|
||||||
@ -279,6 +280,11 @@ Acceptable values are partial names or filetypes of the special buffers. Use
|
|||||||
let g:ctrlp_dont_split = 'netrw\|help'
|
let g:ctrlp_dont_split = 'netrw\|help'
|
||||||
<
|
<
|
||||||
|
|
||||||
|
*'g:ctrlp_follow_symlinks'*
|
||||||
|
Set this to 1 to follow symbolic links when listing files: >
|
||||||
|
let g:ctrlp_follow_symlinks = 0
|
||||||
|
<
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
3. Commands *ctrlp-commands*
|
3. Commands *ctrlp-commands*
|
||||||
|
|
||||||
@ -519,6 +525,8 @@ Special thanks:~
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
CHANGELOG *ctrlp-changelog*
|
CHANGELOG *ctrlp-changelog*
|
||||||
|
|
||||||
|
+ New option: |g:ctrlp_follow_symlinks|
|
||||||
|
|
||||||
Before 2011/11/13~
|
Before 2011/11/13~
|
||||||
|
|
||||||
+ New special input: '/' and '\' find root (section 5.e)
|
+ New special input: '/' and '\' find root (section 5.e)
|
||||||
|
Loading…
Reference in New Issue
Block a user