From 3c6182371db8e8ede3789d21b52386569eda2208 Mon Sep 17 00:00:00 2001 From: Kien N Date: Thu, 20 Sep 2012 19:12:54 +0700 Subject: [PATCH] Move the completion function --- autoload/ctrlp.vim | 10 ---------- autoload/ctrlp/utils.vim | 10 ++++++++++ plugin/ctrlp.vim | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 705fc78..f01f208 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1334,16 +1334,6 @@ fu! s:findcommon(items, seed) endfo retu cmn endf - -fu! ctrlp#dircompl(...) - let [hsl, str] = [match(a:1, '[\/]'), ''] - let par = substitute(a:1, '[^\/]*$', '', '') - let path = !hsl ? par : hsl > 0 ? getcwd().s:lash().par : getcwd() - for dir in split(globpath(s:fnesc(path, 'g', ','), '*/'), '\n') - let str .= par.split(dir, '[\/]')[-1]."\n" - endfo - retu str -endf " Misc {{{3 fu! s:headntail(str) let parts = split(a:str, '[\/]\ze[^\/]\+[\/:]\?$') diff --git a/autoload/ctrlp/utils.vim b/autoload/ctrlp/utils.vim index 08dab92..7a74b7f 100644 --- a/autoload/ctrlp/utils.vim +++ b/autoload/ctrlp/utils.vim @@ -105,6 +105,16 @@ fu! ctrlp#utils#fnesc(path, type, ...) en retu a:0 ? escape(path, a:1) : path endf + +fu! ctrlp#utils#dircompl(...) + let [hsl, str] = [match(a:1, '[\/]'), ''] + let par = substitute(a:1, '[^\/]*$', '', '') + let path = !hsl ? par : hsl > 0 ? getcwd().s:lash().par : getcwd() + for dir in split(globpath(ctrlp#utils#fnesc(path, 'g', ','), '*/'), '\n') + let str .= par.split(dir, '[\/]')[-1]."\n" + endfo + retu str +endf "}}} " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index 56c2f39..68cae86 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -17,10 +17,10 @@ let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs, if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en -com! -n=? -com=custom,ctrlp#dircompl CtrlP +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlP \ cal ctrlp#init(0, { 'dir': }) -com! -n=? -com=custom,ctrlp#dircompl CtrlPMRUFiles +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPMRUFiles \ cal ctrlp#init(2, { 'dir': }) com! -bar CtrlPBuffer cal ctrlp#init(1) @@ -45,7 +45,7 @@ cal ctrlp#mrufiles#init() com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id()) com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id()) -com! -n=? -com=custom,ctrlp#dircompl CtrlPDir +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPDir \ cal ctrlp#init(ctrlp#dir#id(), { 'dir': }) com! -n=? -com=buffer CtrlPBufTag @@ -63,7 +63,7 @@ com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) -com! -n=? -com=custom,ctrlp#dircompl CtrlPBookmarkDirAdd +com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPBookmarkDirAdd \ cal ctrlp#call('ctrlp#bookmarkdir#add', ) " vim:ts=2:sw=2:sts=2