Restore unnamed register

* Close #44
* Add help tags for extension's commands. Issue #43.
* Folding tweak.
This commit is contained in:
Kien N 2011-12-03 10:54:18 +07:00
parent b1a8c3d21e
commit af22f30e39
7 changed files with 87 additions and 106 deletions

View File

@ -5,7 +5,7 @@
" Version: 1.6.3 " Version: 1.6.3
" ============================================================================= " =============================================================================
" Static variables {{{ " Static variables {{{1
fu! s:opts() fu! s:opts()
let hst = exists('+hi') ? &hi : 20 let hst = exists('+hi') ? &hi : 20
let opts = { let opts = {
@ -62,8 +62,7 @@ en
" Limiters " Limiters
let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000] let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000]
"}}} " * Open & Close {{{1
" * Open & Close {{{
fu! s:Open() fu! s:Open()
let [s:cwd, s:winres] = [getcwd(), winrestcmd()] let [s:cwd, s:winres] = [getcwd(), winrestcmd()]
let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)] let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)]
@ -102,8 +101,7 @@ fu! s:Close()
cal ctrlp#recordhist() cal ctrlp#recordhist()
ec ec
endf endf
"}}} " * Clear caches {{{1
" * Clear caches {{{
fu! ctrlp#clr(...) fu! ctrlp#clr(...)
exe 'let g:ctrlp_new'.( exists('a:1') ? a:1 : 'cache' ).' = 1' exe 'let g:ctrlp_new'.( exists('a:1') ? a:1 : 'cache' ).' = 1'
endf endf
@ -113,8 +111,8 @@ fu! ctrlp#clra(...)
\ confirm("Delete all cache files?", "&OK\n&Cancel") != 1 | retu | en \ confirm("Delete all cache files?", "&OK\n&Cancel") != 1 | retu | en
let cache_dir = ctrlp#utils#cachedir() let cache_dir = ctrlp#utils#cachedir()
if isdirectory(cache_dir) if isdirectory(cache_dir)
let cache_files = split(s:glbpath(cache_dir, '*.txt', 1), "\n") let cache_files = split(s:glbpath(cache_dir, '**', 1), "\n")
cal filter(cache_files, '!isdirectory(v:val)') cal filter(cache_files, '!isdirectory(v:val) && v:val !~ ''\<cache\.txt$''')
sil! cal map(cache_files, 'delete(v:val)') sil! cal map(cache_files, 'delete(v:val)')
en en
cal ctrlp#clr() cal ctrlp#clr()
@ -128,8 +126,7 @@ fu! ctrlp#reset()
cal ctrlp#mrufiles#opts() cal ctrlp#mrufiles#opts()
unl! s:cline unl! s:cline
endf endf
"}}} " * Files() {{{1
" * 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")
if !s:folsym if !s:folsym
@ -186,8 +183,7 @@ fu! s:Files()
cal s:writecache(read_cache, cache_file) cal s:writecache(read_cache, cache_file)
retu g:ctrlp_allfiles retu g:ctrlp_allfiles
endf endf
"}}} fu! s:Buffers() "{{{1
fu! s:Buffers() "{{{
let allbufs = [] let allbufs = []
for each in range(1, bufnr('$')) for each in range(1, bufnr('$'))
if getbufvar(each, '&bl') && each != bufnr('#') if getbufvar(each, '&bl') && each != bufnr('#')
@ -198,8 +194,8 @@ fu! s:Buffers() "{{{
en en
endfo endfo
retu allbufs retu allbufs
endf "}}} endf
" * MatchedItems() {{{ " * MatchedItems() {{{1
fu! s:MatchIt(items, pat, limit, ispathitem) fu! s:MatchIt(items, pat, limit, ispathitem)
let [items, pat, limit, newitems] = [a:items, a:pat, a:limit, []] let [items, pat, limit, newitems] = [a:items, a:pat, a:limit, []]
let mfunc = s:byfname && a:ispathitem ? 's:matchfname' let mfunc = s:byfname && a:ispathitem ? 's:matchfname'
@ -234,8 +230,7 @@ fu! s:MatchedItems(items, pats, limit)
let s:matches = len(newitems) let s:matches = len(newitems)
retu newitems retu newitems
endf endf
"}}} fu! s:SplitPattern(str, ...) "{{{1
fu! s:SplitPattern(str, ...) "{{{
let str = s:sanstail(a:str) let str = s:sanstail(a:str)
if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo') if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo')
let dict = s:glbpath(&rtp, printf("dict/%s/migemo-dict", &encoding), 1) let dict = s:glbpath(&rtp, printf("dict/%s/migemo-dict", &encoding), 1)
@ -275,8 +270,8 @@ fu! s:SplitPattern(str, ...) "{{{
endfo endfo
en en
retu newpats retu newpats
endf "}}} endf
" * BuildPrompt() {{{ " * BuildPrompt() {{{1
fu! s:Render(lines, pat) fu! s:Render(lines, pat)
let lines = a:lines let lines = a:lines
" Setup the match window " Setup the match window
@ -360,9 +355,8 @@ fu! s:BuildPrompt(upd, ...)
exe 'echoh' hibase '| echon "_" | echoh None' exe 'echoh' hibase '| echon "_" | echoh None'
en en
endf endf
"}}} " ** Prt Actions {{{1
" ** Prt Actions {{{ " Editing {{{2
" Editing {{{
fu! s:PrtClear() fu! s:PrtClear()
unl! s:hstgot unl! s:hstgot
let [s:prompt, s:matches] = [['', '', ''], 1] let [s:prompt, s:matches] = [['', '', ''], 1]
@ -410,8 +404,7 @@ fu! s:PrtInsert(type)
\ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') : s:prompt[0] \ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') : s:prompt[0]
cal s:BuildPrompt(1) cal s:BuildPrompt(1)
endf endf
"}}} " Movement {{{2
" Movement {{{
fu! s:PrtCurLeft() fu! s:PrtCurLeft()
if !empty(s:prompt[0]) if !empty(s:prompt[0])
let prt = s:prompt let prt = s:prompt
@ -472,8 +465,7 @@ fu! s:PrtSelectJump(char, ...)
if line('$') > winheight(0) | cal s:BuildPrompt(0, s:Focus()) | en if line('$') > winheight(0) | cal s:BuildPrompt(0, s:Focus()) | en
en en
endf endf
"}}} " Misc {{{2
" Misc {{{
fu! s:PrtClearCache() fu! s:PrtClearCache()
if s:itemtype == 1 | retu | en if s:itemtype == 1 | retu | en
if s:itemtype == 0 if s:itemtype == 0
@ -518,9 +510,8 @@ fu! s:PrtHistory(...)
cal s:BuildPrompt(1) cal s:BuildPrompt(1)
unl s:force unl s:force
endf endf
"}}} "}}}1
"}}} " * MapKeys() {{{1
" * MapKeys() {{{
fu! s:MapKeys(...) fu! s:MapKeys(...)
" Normal keys " Normal keys
let pfunc = exists('a:1') && !a:1 ? 'PrtSelectJump' : 'PrtAdd' let pfunc = exists('a:1') && !a:1 ? 'PrtSelectJump' : 'PrtAdd'
@ -604,8 +595,7 @@ fu! s:MapSpecs(...)
endfo | endfo endfo | endfo
en en
endf endf
"}}} " * Toggling {{{1
" * Toggling {{{
fu! s:Focus() fu! s:Focus()
retu !exists('s:focus') ? 1 : s:focus retu !exists('s:focus') ? 1 : s:focus
endf endf
@ -650,8 +640,7 @@ fu! s:PrtSwitcher()
cal s:BuildPrompt(1, s:Focus()) cal s:BuildPrompt(1, s:Focus())
unl s:force unl s:force
endf endf
"}}} fu! s:SetWD(...) "{{{1
fu! s:SetWD(...) "{{{
let pathmode = s:pathmode let pathmode = s:pathmode
if exists('a:1') && len(a:1) == 1 && !type(a:1) if exists('a:1') && len(a:1) == 1 && !type(a:1)
let pathmode = a:1 let pathmode = a:1
@ -673,8 +662,8 @@ fu! s:SetWD(...) "{{{
if exists('s:foundroot') | brea | en if exists('s:foundroot') | brea | en
endfo endfo
unl! s:foundroot unl! s:foundroot
endf "}}} endf
" * AcceptSelection() {{{ " * AcceptSelection() {{{1
fu! ctrlp#acceptfile(mode, matchstr) fu! ctrlp#acceptfile(mode, matchstr)
let [md, matchstr] = [a:mode, a:matchstr] let [md, matchstr] = [a:mode, a:matchstr]
" Get the full path " Get the full path
@ -711,8 +700,7 @@ fu! s:AcceptSelection(mode)
\ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][1] \ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][1]
cal call(actfunc, [a:mode, matchstr]) cal call(actfunc, [a:mode, matchstr])
endf endf
"}}} fu! s:CreateNewFile() "{{{1
fu! s:CreateNewFile() "{{{
let str = join(s:prompt, '') let str = join(s:prompt, '')
if empty(str) | retu | en if empty(str) | retu | en
let str = s:sanstail(str) let str = s:sanstail(str)
@ -732,8 +720,8 @@ fu! s:CreateNewFile() "{{{
\ : s:newfop == 3 ? 'vne' : ctrlp#normcmd('e') \ : s:newfop == 3 ? 'vne' : ctrlp#normcmd('e')
cal s:openfile(cmd, filpath) cal s:openfile(cmd, filpath)
en en
endf "}}} endf
" * OpenMulti() {{{ " * OpenMulti() {{{1
fu! s:MarkToOpen() fu! s:MarkToOpen()
if s:bufnr <= 0 || !s:opmul || s:itemtype > g:ctrlp_builtins | retu | en if s:bufnr <= 0 || !s:opmul || s:itemtype > g:ctrlp_builtins | retu | en
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$') let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
@ -794,9 +782,8 @@ fu! s:OpenMulti()
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
"}}} " ** Helper functions {{{1
" ** Helper functions {{{ " Sorting {{{2
" Sorting {{{
fu! ctrlp#complen(s1, s2) fu! ctrlp#complen(s1, s2)
" By length " By length
let [len1, len2] = [strlen(a:s1), strlen(a:s2)] let [len1, len2] = [strlen(a:s1), strlen(a:s2)]
@ -856,8 +843,7 @@ fu! s:mixedsort(s1, s2)
en en
retu 2 * cml + cln retu 2 * cml + cln
endf endf
"}}} " Statusline {{{2
" Statusline {{{
fu! ctrlp#statusline(...) fu! ctrlp#statusline(...)
if !exists('s:statypes') if !exists('s:statypes')
let s:statypes = [ let s:statypes = [
@ -896,8 +882,7 @@ fu! ctrlp#progress(len)
let &l:stl = '%#Function# '.a:len.' %* %=%<%#LineNr# '.getcwd().' %*' let &l:stl = '%#Function# '.a:len.' %* %=%<%#LineNr# '.getcwd().' %*'
redr redr
endf endf
"}}} " Paths {{{2
" Paths {{{
fu! ctrlp#dirfilter(val) fu! ctrlp#dirfilter(val)
retu isdirectory(a:val) && match(a:val, '[\/]\.\{,2}$') < 0 ? 1 : 0 retu isdirectory(a:val) && match(a:val, '[\/]\.\{,2}$') < 0 ? 1 : 0
endf endf
@ -969,7 +954,7 @@ fu! s:findroot(curr, mark, depth, type)
endf endf
fu! s:glbpath(...) fu! s:glbpath(...)
retu call('globpath', v:version > 701 ? [a:1, a:2, a:3] : [a:1, a:2]) retu call('globpath', v:version > 701 ? a:000 : a:000[:1])
endf endf
fu! ctrlp#fnesc(path) fu! ctrlp#fnesc(path)
@ -984,8 +969,7 @@ fu! ctrlp#setdir(path, ...)
cal ctrlp#msg("Can't change working dir. Directory not exists.") cal ctrlp#msg("Can't change working dir. Directory not exists.")
endt endt
endf endf
"}}} " Highlighting {{{2
" Highlighting {{{
fu! s:syntax() fu! s:syntax()
sy match CtrlPNoEntries '^ == NO ENTRIES ==$' sy match CtrlPNoEntries '^ == NO ENTRIES ==$'
sy match CtrlPLineMarker '^>' sy match CtrlPLineMarker '^>'
@ -1012,8 +996,7 @@ fu! s:dohighlight()
retu type(s:mathi) == 3 && len(s:mathi) == 2 && s:mathi[0] retu type(s:mathi) == 3 && len(s:mathi) == 2 && s:mathi[0]
\ && exists('*clearmatches') \ && exists('*clearmatches')
endf endf
"}}} " Prompt history {{{2
" Prompt history {{{
fu! s:gethistloc() fu! s:gethistloc()
let cache_dir = ctrlp#utils#cachedir().s:lash.'hist' let cache_dir = ctrlp#utils#cachedir().s:lash.'hist'
retu [cache_dir, cache_dir.s:lash.'cache.txt'] retu [cache_dir, cache_dir.s:lash.'cache.txt']
@ -1031,8 +1014,7 @@ fu! ctrlp#recordhist()
cal extend(hst, [str], 1) cal extend(hst, [str], 1)
if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en
endf endf
"}}} " Signs {{{2
" Signs {{{
fu! s:unmarksigns() fu! s:unmarksigns()
if !s:dosigns() | retu | en if !s:dosigns() | retu | en
for key in keys(s:marked) for key in keys(s:marked)
@ -1055,8 +1037,7 @@ endf
fu! s:dosigns() fu! s:dosigns()
retu exists('s:marked') && s:bufnr > 0 && s:opmul && has('signs') retu exists('s:marked') && s:bufnr > 0 && s:opmul && has('signs')
endf endf
"}}} " Dictionaries {{{2
" Dictionaries {{{
fu! s:dictindex(dict, expr) fu! s:dictindex(dict, expr)
for key in keys(a:dict) for key in keys(a:dict)
if a:dict[key] == a:expr | retu key | en if a:dict[key] == a:expr | retu key | en
@ -1067,8 +1048,7 @@ endf
fu! s:vacantdict(dict) fu! s:vacantdict(dict)
retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)') retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)')
endf endf
"}}} " Buffers {{{2
" Buffers {{{
fu! s:buftab(bufnum) fu! s:buftab(bufnum)
for nr in range(1, tabpagenr('$')) for nr in range(1, tabpagenr('$'))
let buflist = tabpagebuflist(nr) let buflist = tabpagebuflist(nr)
@ -1121,7 +1101,10 @@ fu! s:setupblank()
endf endf
fu! s:leavepre() fu! s:leavepre()
if s:clrex | cal ctrlp#clra(1) | en if s:clrex && ( !has('clientserver') ||
\ ( has('clientserver') && len(split(serverlist(), "\n")) == 1 ) )
cal ctrlp#clra(1)
en
cal ctrlp#utils#writecache(s:hstry, s:gethistloc()[0], s:gethistloc()[1]) cal ctrlp#utils#writecache(s:hstry, s:gethistloc()[0], s:gethistloc()[1])
endf endf
@ -1131,8 +1114,7 @@ fu! s:checkbuf()
exe s:bufnr.'bw!' exe s:bufnr.'bw!'
en en
endf endf
"}}} " Arguments {{{2
" Arguments {{{
fu! s:tail() fu! s:tail()
if exists('s:optail') && !empty('s:optail') if exists('s:optail') && !empty('s:optail')
let tailpref = match(s:optail, '^\s*+') < 0 ? ' +' : ' ' let tailpref = match(s:optail, '^\s*+') < 0 ? ' +' : ' '
@ -1151,8 +1133,7 @@ fu! s:sanstail(str)
en en
retu str retu str
endf endf
"}}} " Misc {{{2
" Misc {{{
fu! s:specinputs() fu! s:specinputs()
let str = join(s:prompt, '') let str = join(s:prompt, '')
let type = s:itemtype > 2 ? let type = s:itemtype > 2 ?
@ -1177,10 +1158,13 @@ fu! s:specinputs()
endf endf
fu! s:lastvisual() fu! s:lastvisual()
let [cview, oreg, oreg_type] = [winsaveview(), getreg('v'), getregtype('v')] let cview = winsaveview()
let [ovreg, ovtype] = [getreg('v'), getregtype('v')]
let [oureg, outype] = [getreg('"'), getregtype('"')]
sil! norm! gv"vy sil! norm! gv"vy
let selected = substitute(getreg('v'), '\n', '\\n', 'g') let selected = substitute(getreg('v'), '\n', '\\n', 'g')
cal setreg('v', oreg, oreg_type) cal setreg('v', ovreg, ovtype)
cal setreg('"', oureg, outype)
cal winrestview(cview) cal winrestview(cview)
retu selected retu selected
endf endf
@ -1274,8 +1258,7 @@ fu! s:lscommand()
retu cmd[1] retu cmd[1]
en en
endf endf
"}}} " Extensions {{{2
" Extensions {{{
fu! s:tagfiles() fu! s:tagfiles()
retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)') retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)')
endf endf
@ -1291,9 +1274,8 @@ endf
fu! ctrlp#setlines(type) fu! ctrlp#setlines(type)
cal s:SetLines(a:type) cal s:SetLines(a:type)
endf endf
"}}} "}}}1
"}}} " * Initialization {{{1
" * Initialization {{{
fu! s:SetLines(type) fu! s:SetLines(type)
let s:itemtype = a:type let s:itemtype = a:type
let types = [ let types = [
@ -1315,10 +1297,11 @@ fu! ctrlp#init(type, ...)
cal s:MapKeys() cal s:MapKeys()
cal s:SetLines(a:type) cal s:SetLines(a:type)
cal s:BuildPrompt(1) cal s:BuildPrompt(1)
if has('syntax') && exists('g:syntax_on') | cal s:syntax() | en if has('syntax') && exists('g:syntax_on')
cal s:syntax()
en
endf endf
"}}} if has('autocmd') "{{{1
if has('autocmd') "{{{
aug CtrlPAug aug CtrlPAug
au! au!
au BufEnter ControlP cal s:checkbuf() au BufEnter ControlP cal s:checkbuf()
@ -1330,4 +1313,4 @@ if has('autocmd') "{{{
aug END aug END
en "}}} en "}}}
" vim:fen:fdl=0:fdc=1:ts=2:sw=2:sts=2 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -4,7 +4,7 @@
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" ============================================================================= " =============================================================================
" Init {{{ " Init {{{1
if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
fini fini
en en
@ -26,8 +26,7 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:dir_var) : [s:dir_var] \ ? add(g:ctrlp_ext_vars, s:dir_var) : [s:dir_var]
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
"}}} " Utilities {{{1
" Utilities {{{
fu! s:globdirs(dirs, depth) fu! s:globdirs(dirs, depth)
let entries = split(globpath(a:dirs, s:glob), "\n") let entries = split(globpath(a:dirs, s:glob), "\n")
if !s:folsym if !s:folsym
@ -47,8 +46,7 @@ endf
fu! s:max(len, max) fu! s:max(len, max)
retu a:max && a:len > a:max ? 1 : 0 retu a:max && a:len > a:max ? 1 : 0
endf endf
"}}} " Public {{{1
" Public {{{
fu! ctrlp#dir#init(...) fu! ctrlp#dir#init(...)
let s:cwd = getcwd() let s:cwd = getcwd()
for each in range(len(s:ars)) for each in range(len(s:ars))
@ -94,4 +92,4 @@ fu! ctrlp#dir#id()
endf endf
"}}} "}}}
" vim:fen:fdl=0:ts=2:sw=2:sts=2 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -4,7 +4,7 @@
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" ============================================================================= " =============================================================================
" Static variables {{{ " Static variables {{{1
fu! ctrlp#mrufiles#opts() fu! ctrlp#mrufiles#opts()
let opts = { let opts = {
\ 'g:ctrlp_mruf_max': ['s:max', 250], \ 'g:ctrlp_mruf_max': ['s:max', 250],
@ -17,8 +17,7 @@ fu! ctrlp#mrufiles#opts()
endfo endfo
endf endf
cal ctrlp#mrufiles#opts() cal ctrlp#mrufiles#opts()
"}}} fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
fu! ctrlp#mrufiles#list(bufnr, ...) "{{{
if s:locked | retu | en if s:locked | retu | en
" Get the list " Get the list
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru' let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
@ -53,8 +52,8 @@ fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
cal filter(a:mrufs, '!empty(ctrlp#utils#glob(v:val, 1))') cal filter(a:mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
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
fu! ctrlp#mrufiles#init() "{{{ fu! ctrlp#mrufiles#init() "{{{1
let s:locked = 0 let s:locked = 0
aug CtrlPMRUF aug CtrlPMRUF
au! au!
@ -63,6 +62,7 @@ fu! ctrlp#mrufiles#init() "{{{
au QuickFixCmdPre *vimgrep* let s:locked = 1 au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0 au QuickFixCmdPost *vimgrep* let s:locked = 0
aug END aug END
endf "}}} endf
"}}}
" vim:fen:fdl=0:fdc=1:ts=2:sw=2:sts=2 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -4,7 +4,7 @@
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" ============================================================================= " =============================================================================
" Init {{{ " Init {{{1
if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
fini fini
en en
@ -22,8 +22,7 @@ fu! s:lineout(dict)
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'], retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S')) \ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
endf endf
"}}} " Public {{{1
" Public {{{
fu! ctrlp#quickfix#init() fu! ctrlp#quickfix#init()
let g:ctrlp_nolimit = 1 let g:ctrlp_nolimit = 1
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|' sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
@ -53,4 +52,4 @@ fu! ctrlp#quickfix#id()
endf endf
"}}} "}}}
" vim:fen:fdl=0:ts=2:sw=2:sts=2 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -4,7 +4,7 @@
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" ============================================================================= " =============================================================================
" Init {{{ " Init {{{1
if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
fini fini
en en
@ -17,8 +17,7 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:tag_var) : [s:tag_var] \ ? add(g:ctrlp_ext_vars, s:tag_var) : [s:tag_var]
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
"}}} " Utilities {{{1
" Utilities {{{
fu! s:nodup(items) fu! s:nodup(items)
let dict = {} let dict = {}
for each in a:items for each in a:items
@ -31,7 +30,7 @@ fu! s:findcount(str)
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$') let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
let [&l:tags, fname] = [s:ltags, expand(fname, 1)] let [&l:tags, fname] = [s:ltags, expand(fname, 1)]
let tgs = taglist('^'.tg.'$') let tgs = taglist('^'.tg.'$')
if empty(tgs) | retu [0, 0] | en if empty(tgs) | retu [1, 1] | en
let [fnd, ct, pos] = [0, 0, 0] let [fnd, ct, pos] = [0, 0, 0]
for each in tgs for each in tgs
let ct += 1 let ct += 1
@ -45,8 +44,7 @@ fu! s:findcount(str)
endfo endfo
retu [fnd, pos] retu [fnd, pos]
endf endf
"}}} " Public {{{1
" Public {{{
fu! ctrlp#tag#init(tagfiles) fu! ctrlp#tag#init(tagfiles)
if empty(a:tagfiles) | retu [] | en if empty(a:tagfiles) | retu [] | en
let tagfiles = sort(s:nodup(a:tagfiles)) let tagfiles = sort(s:nodup(a:tagfiles))
@ -78,7 +76,6 @@ fu! ctrlp#tag#accept(mode, str)
if fnd[0] == 1 if fnd[0] == 1
exe cmd exe cmd
let &l:tags = s:ltags let &l:tags = s:ltags
let tg = tg =~ '^!' ? substitute(tg, '!\(.*\)$', '/^!\1$', '') : tg
exe fnd[1].'ta' tg exe fnd[1].'ta' tg
el el
exe cmd.' '.tg exe cmd.' '.tg
@ -93,4 +90,4 @@ fu! ctrlp#tag#id()
endf endf
"}}} "}}}
" vim:fen:fdl=0:ts=2:sw=2:sts=2 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -4,7 +4,7 @@
" Author: Kien Nguyen <github.com/kien> " Author: Kien Nguyen <github.com/kien>
" ============================================================================= " =============================================================================
" Static variables {{{ " Static variables {{{1
fu! ctrlp#utils#lash() fu! ctrlp#utils#lash()
retu &ssl || !exists('+ssl') ? '/' : '\' retu &ssl || !exists('+ssl') ? '/' : '\'
endf endf
@ -20,8 +20,7 @@ fu! ctrlp#utils#opts()
en en
endf endf
cal ctrlp#utils#opts() cal ctrlp#utils#opts()
"}}} " Files and Directories {{{1
" Files and Directories {{{
fu! ctrlp#utils#cachedir() fu! ctrlp#utils#cachedir()
retu s:cache_dir retu s:cache_dir
endf endf
@ -62,8 +61,8 @@ fu! ctrlp#utils#writecache(lines, ...)
endf endf
fu! ctrlp#utils#glob(...) fu! ctrlp#utils#glob(...)
retu call('glob', v:version > 701 ? [a:1, a:2] : [a:1]) retu call('glob', v:version > 701 ? a:000 : a:1)
endf endf
"}}} "}}}
" vim:fen:fdl=0:fdc=1:ts=2:sw=2:sts=2 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -496,16 +496,18 @@ f) Type the name of a non-existent file and press <c-y> to create it.
g) Submit ? to open this help file. g) Submit ? to open this help file.
=============================================================================== ===============================================================================
6. Extensions *ctrlp-extensions* 6. Extensions *g:ctrlp-extensions*
Extensions are optional. To enable an extension, add its name to the variable Extensions are optional. To enable an extension, add its name to the variable
g:ctrlp_extensions: > g:ctrlp_extensions: >
let g:ctrlp_extensions = ['tag', 'quickfix', 'dir'] let g:ctrlp_extensions = ['tag', 'quickfix', 'buffertag', 'dir']
< <
The order of the items will be the order they appear on the statusline and when
using <c-f>, <c-b>.
Available extensions:~ Available extensions:~
*ctrlp-tag-mode* *:CtrlPTag*
* Tag mode:~ * Tag mode:~
- Name: 'tag' - Name: 'tag'
- Command: ':CtrlPTag' - Command: ':CtrlPTag'
@ -513,13 +515,13 @@ Available extensions:~
definition. Use the Vims option |'tags'| to specify the names and the definition. Use the Vims option |'tags'| to specify the names and the
locations of the tags file(s). Example: `set tags+=tags/help,doc/tags` locations of the tags file(s). Example: `set tags+=tags/help,doc/tags`
*ctrlp-quickfix-mode* *:CtrlPQuickfix*
* Quickfix mode:~ * Quickfix mode:~
- Name: 'quickfix' - Name: 'quickfix'
- Command: ':CtrlPQuickfix' - Command: ':CtrlPQuickfix'
- Search for an entry in the current quickfix errors and jump to it. - Search for an entry in the current quickfix errors and jump to it.
*ctrlp-dir-mode* *:CtrlPDir*
* Directory mode:~ * Directory mode:~
- Name: 'dir' - Name: 'dir'
- Command: ':CtrlPDir' - Command: ':CtrlPDir'
@ -581,7 +583,10 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
Before 2011/11/30~
+ New features: Tag, Quickfix and Directory extensions. + New features: Tag, Quickfix and Directory extensions.
+ New commands: |:CtrlPTag|, |:CtrlPQuickfix|, |:CtrlPDir|.
+ New options: |g:ctrlp_use_migemo|, + New options: |g:ctrlp_use_migemo|,
|g:ctrlp_lazy_update|, |g:ctrlp_lazy_update|,
|g:ctrlp_follow_symlinks| |g:ctrlp_follow_symlinks|