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