some clean up
This commit is contained in:
parent
d8ca2990d2
commit
6339308c72
@ -200,7 +200,7 @@ func! s:SplitPattern(str,...) "{{{
|
||||
if len(array) > 1
|
||||
for i in range(1, len(array) - 1)
|
||||
" Separator
|
||||
let sp = exists('a:1') ? a:1 : '.*'
|
||||
let sp = exists('a:1') ? a:1 : '.\{-}'
|
||||
let nitem .= sp.array[i]
|
||||
cal add(newpats, nitem)
|
||||
endfor
|
||||
@ -375,7 +375,6 @@ func! s:UpdateMatches(pat) "{{{
|
||||
let newpat = s:SplitPattern(a:pat)
|
||||
let lines = s:GetMatchedItems(s:lines, newpat, s:mxheight)
|
||||
cal s:Renderer(lines)
|
||||
"cal s:Highlight(newpat)
|
||||
endfunc "}}}
|
||||
|
||||
func! s:BuildPrompt(...) "{{{
|
||||
@ -620,23 +619,12 @@ func! s:Type(type) "{{{
|
||||
cal s:BuildPrompt(s:Focus())
|
||||
endfunc "}}}
|
||||
|
||||
"Mightdo: Highlight matched characters/strings. /low
|
||||
func! s:Highlight(...) "{{{
|
||||
hi clear CtrlPKeywords
|
||||
hi link CtrlPKeywords Normal
|
||||
if exists('a:1') && !empty(a:1)
|
||||
let pat = substitute(a:1[-1], ':\d*$', '', 'g')
|
||||
exe 'syn match CtrlPKeywords /\c'.pat.'/'
|
||||
hi link CtrlPKeywords Constant
|
||||
endif
|
||||
endfunc "}}}
|
||||
|
||||
" ctrlp#SetWorkingPath(...) {{{
|
||||
func! s:FindRoot(curr, mark)
|
||||
if !empty(globpath(a:curr, a:mark))
|
||||
exe 'chdir' a:curr
|
||||
else
|
||||
let parent = substitute(a:curr, '[\/]\zs[^\/]\+[\/]*$', '', '')
|
||||
let parent = substitute(a:curr, '[\/]\zs[^\/]\+[\/]\?$', '', '')
|
||||
if parent != a:curr
|
||||
cal s:FindRoot(parent, a:mark)
|
||||
endif
|
||||
@ -715,7 +703,6 @@ func! s:AcceptSelection(mode,...) "{{{
|
||||
ec
|
||||
endfunc "}}}
|
||||
|
||||
"Mightdo: Further customizing s:compare(). Sort by file type. /low
|
||||
" Helper functions {{{
|
||||
func! s:compare(s1, s2)
|
||||
" by length
|
||||
@ -780,6 +767,13 @@ func! s:syntax()
|
||||
hi link CtrlPNoEntries Error
|
||||
hi CtrlPLineMarker guifg=bg
|
||||
endfunc
|
||||
|
||||
func! s:uniquefilter(val, pats)
|
||||
for each in a:pats
|
||||
if match(each, a:val) >= 0 && len(a:val) < len(each) | retu 0 | endif
|
||||
endfor
|
||||
retu 1
|
||||
endfunc
|
||||
"}}}
|
||||
|
||||
func! s:SetLines(type) "{{{
|
||||
@ -800,8 +794,12 @@ func! s:hooks(type) "{{{
|
||||
retu eval(types[a:type])
|
||||
endfunc "}}}
|
||||
|
||||
func! ctrlp#init(type) "{{{
|
||||
sil! cal ctrlp#SetWorkingPath()
|
||||
func! ctrlp#init(type, ...) "{{{
|
||||
if exists('a:1')
|
||||
sil! cal ctrlp#SetWorkingPath(a:1)
|
||||
else
|
||||
sil! cal ctrlp#SetWorkingPath()
|
||||
endif
|
||||
sil! cal s:SetLines(a:type)
|
||||
sil! cal s:BufOpen('ControlP')
|
||||
sil! cal s:SetupBlank()
|
||||
|
@ -209,6 +209,16 @@ Examples: >
|
||||
:ClearAllCtrlPCaches
|
||||
Delete all the saved cache files in |ctrlp_cache_dir|.
|
||||
|
||||
*:CtrlPCurDir*
|
||||
:CtrlPCurDir
|
||||
Find files in the same directory as the current file, recursively.
|
||||
This command ignores the current value of |g:ctrlp_working_path_mode|.
|
||||
|
||||
*:CtrlPRoot*
|
||||
:CtrlPRoot
|
||||
Same as |:CtrlPCurDir| but from the project’s root.
|
||||
Also ignores the current value of |g:ctrlp_working_path_mode|.
|
||||
|
||||
===============================================================================
|
||||
4. Mappings *ctrlp-mappings*
|
||||
|
||||
@ -302,7 +312,7 @@ Chose your own mappings with |g:ctrlp_prompt_mappings|.
|
||||
*ctrlp-prompt-input-formats*
|
||||
Formats for inputting in the prompt:
|
||||
|
||||
a) Simple string. e.g. 'abc' is understood internally as 'a.*b.*c'
|
||||
a) Simple string. e.g. 'abc' is understood internally as 'a.\{-}b.\{-}c'
|
||||
|
||||
b) Vim |regexp|. If the input string contains '*', '^', '$', '+' or '$', it’ll
|
||||
be treated as a Vim’s |regexp| |pattern| without any modification.
|
||||
@ -336,6 +346,8 @@ CHANGELOG
|
||||
*ctrlp-update-2*
|
||||
Update #2~
|
||||
+ New mapping: <F5>.
|
||||
+ New commands: |:CtrlPRoot|,
|
||||
|:CtrlPCurDir|
|
||||
|
||||
*ctrlp-update-1*
|
||||
Update #1~
|
||||
|
@ -19,6 +19,9 @@ com! CtrlPMRUFiles cal ctrlp#init(2)
|
||||
com! ClearCtrlPCache cal ctrlp#clearcache()
|
||||
com! ClearAllCtrlPCaches cal ctrlp#clearallcaches()
|
||||
|
||||
com! CtrlPRoot cal ctrlp#init(0, 2)
|
||||
com! CtrlPCurDir cal ctrlp#init(0, 1)
|
||||
|
||||
exe 'nn <silent>' g:ctrlp_map ':<c-u>CtrlP<cr>'
|
||||
|
||||
if g:ctrlp_mru_files | cal ctrlp#mrufiles#init() | endif
|
||||
|
Loading…
Reference in New Issue
Block a user