diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index b85d908..6d17d99 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -11,8 +11,8 @@ fu! s:opts() let hst = exists('+hi') ? &hi : 20 let [pref, opts] = ['g:ctrlp_', { \ 'arg_map': ['s:argmap', 0], - \ 'by_filename': ['s:byfname', 0], \ 'buffer_func': ['s:buffunc', {}], + \ 'by_filename': ['s:byfname', 0], \ 'clear_cache_on_exit': ['s:clrex', 1], \ 'custom_ignore': ['s:usrign', ''], \ 'default_input': ['s:deftxt', 0], @@ -713,10 +713,11 @@ fu! s:ToggleByFname() endf fu! s:ToggleType(dir) - let ext = exists('g:ctrlp_ext_vars') ? len(g:ctrlp_ext_vars) : 0 + let max = len(g:ctrlp_ext_vars) + 2 + let next = s:walker(max, s:itemtype, a:dir) unl! g:ctrlp_nolimit cal ctrlp#syntax() - cal ctrlp#setlines(s:walker(2 + ext, s:itemtype, a:dir)) + cal ctrlp#setlines(next) cal s:PrtSwitcher() endf @@ -1037,7 +1038,7 @@ fu! ctrlp#statusline() \ ['buffers', 'buf'], \ ['mru files', 'mru'], \ ] - if exists('g:ctrlp_ext_vars') + if !empty(g:ctrlp_ext_vars) cal map(copy(g:ctrlp_ext_vars), \ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])') en @@ -1591,7 +1592,7 @@ fu! s:mtype() endf fu! s:execextvar(key) - if exists('g:ctrlp_ext_vars') + if !empty(g:ctrlp_ext_vars) cal map(filter(copy(g:ctrlp_ext_vars), \ 'has_key(v:val, a:key)'), 'eval(v:val[a:key])') en @@ -1632,7 +1633,7 @@ fu! ctrlp#setlines(...) if a:0 | let s:itemtype = a:1 | en cal s:modevar() let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()'] - if exists('g:ctrlp_ext_vars') + if !empty(g:ctrlp_ext_vars) cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])') en let g:ctrlp_lines = eval(types[s:itemtype]) diff --git a/autoload/ctrlp/buffertag.vim b/autoload/ctrlp/buffertag.vim index a8a99f9..b746c40 100644 --- a/autoload/ctrlp/buffertag.vim +++ b/autoload/ctrlp/buffertag.vim @@ -13,7 +13,7 @@ if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag en let g:loaded_ctrlp_buftag = 1 -let s:buftag_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#buffertag#init(s:crfile)', \ 'accept': 'ctrlp#buffertag#accept', \ 'lname': 'buffer tags', @@ -21,10 +21,7 @@ let s:buftag_var = { \ 'exit': 'ctrlp#buffertag#exit()', \ 'type': 'tabs', \ 'opts': 'ctrlp#buffertag#opts()', - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:buftag_var) : [s:buftag_var] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) @@ -199,13 +196,14 @@ fu! s:parseline(line) endf fu! s:syntax() - if ctrlp#nosy() | retu | en - cal ctrlp#hicheck('CtrlPTagKind', 'Title') - cal ctrlp#hicheck('CtrlPBufName', 'Directory') - cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') - sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|' - sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|' - sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPTagKind', 'Title') + cal ctrlp#hicheck('CtrlPBufName', 'Directory') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|' + sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|' + sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind + en endf " Public {{{1 fu! ctrlp#buffertag#init(fname) diff --git a/autoload/ctrlp/changes.vim b/autoload/ctrlp/changes.vim index ecc370f..0e78cce 100644 --- a/autoload/ctrlp/changes.vim +++ b/autoload/ctrlp/changes.vim @@ -10,7 +10,7 @@ if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes en let g:loaded_ctrlp_changes = 1 -let s:changes_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#changes#init(s:bufnr, s:crfile)', \ 'accept': 'ctrlp#changes#accept', \ 'lname': 'changes', @@ -18,10 +18,7 @@ let s:changes_var = { \ 'exit': 'ctrlp#changes#exit()', \ 'type': 'tabe', \ 'sort': 0, - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:changes_var) : [s:changes_var] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 @@ -46,11 +43,12 @@ fu! s:process(clines, ...) endf fu! s:syntax() - if ctrlp#nosy() | retu | en - cal ctrlp#hicheck('CtrlPBufName', 'Directory') - cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') - sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$' - sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPBufName', 'Directory') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$' + sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName + en endf " Public {{{1 fu! ctrlp#changes#init(original_bufnr, fname) diff --git a/autoload/ctrlp/dir.vim b/autoload/ctrlp/dir.vim index 5b44fc7..3c56533 100644 --- a/autoload/ctrlp/dir.vim +++ b/autoload/ctrlp/dir.vim @@ -17,17 +17,14 @@ let s:ars = [ \ 's:glob', \ ] -let s:dir_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')', \ 'accept': 'ctrlp#dir#accept', \ 'lname': 'dirs', \ 'sname': 'dir', \ 'type': 'path', \ 'specinput': 1, - \ } - -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] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 @@ -51,8 +48,8 @@ fu! ctrlp#dir#init(...) for each in range(len(s:ars)) exe 'let' s:ars[each] '=' string(eval('a:'.(each + 1))) endfo - let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var['sname'] - let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var['sname']) + let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir' + let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir') if g:ctrlp_newdir || !filereadable(cafile) let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []] cal s:globdirs(s:cwd, 0) diff --git a/autoload/ctrlp/line.vim b/autoload/ctrlp/line.vim index d5a2c57..2a2bf73 100644 --- a/autoload/ctrlp/line.vim +++ b/autoload/ctrlp/line.vim @@ -10,40 +10,37 @@ if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line en let g:loaded_ctrlp_line = 1 -let s:line_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#line#init()', \ 'accept': 'ctrlp#line#accept', \ 'lname': 'lines', \ 'sname': 'lns', \ 'type': 'tabe', - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:line_var) : [s:line_var] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 fu! s:syntax() - if ctrlp#nosy() | retu | en - cal ctrlp#hicheck('CtrlPBufName', 'Directory') - cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') - sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$' - sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName + if !ctrlp#nosy() + cal ctrlp#hicheck('CtrlPBufName', 'Directory') + cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') + sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$' + sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName + en endf " Public {{{1 fu! ctrlp#line#init() let [bufs, lines] = [filter(ctrlp#buffers(), 'filereadable(v:val)'), []] for each in bufs - let [fnamet, from_file] = [fnamemodify(each, ':t'), readfile(each)] + let [fnamet, ff] = [fnamemodify(each, ':t'), readfile(each)] let bname = fnamemodify(each, ':p') - cal map(from_file, 'tr(v:val, '' '', '' '')') - let [id, len_ff, bufnr] = [1, len(from_file), bufnr('^'.bname.'$')] + cal map(ff, 'tr(v:val, '' '', '' '')') + let [id, len_ff, bufnr] = [1, len(ff), bufnr('^'.bname.'$')] wh id <= len_ff - let from_file[id-1] .= ' |'.fnamet.'|'.bufnr.':'.id.'|' + let ff[id-1] .= ' |'.fnamet.'|'.bufnr.':'.id.'|' let id += 1 endw - cal filter(from_file, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''') - cal extend(lines, from_file) + cal extend(lines, filter(ff, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')) endfo cal s:syntax() retu lines diff --git a/autoload/ctrlp/mixed.vim b/autoload/ctrlp/mixed.vim index 4fc4242..065a847 100644 --- a/autoload/ctrlp/mixed.vim +++ b/autoload/ctrlp/mixed.vim @@ -10,7 +10,7 @@ if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed en let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0] -let s:mixed_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#mixed#init(s:compare_lim)', \ 'accept': 'ctrlp#acceptfile', \ 'lname': 'fil + mru + buf', @@ -18,10 +18,7 @@ let s:mixed_var = { \ 'type': 'path', \ 'opmul': 1, \ 'specinput': 1, - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:mixed_var) : [s:mixed_var] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 diff --git a/autoload/ctrlp/quickfix.vim b/autoload/ctrlp/quickfix.vim index 0878a90..5be1fea 100644 --- a/autoload/ctrlp/quickfix.vim +++ b/autoload/ctrlp/quickfix.vim @@ -10,17 +10,14 @@ if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix en let g:loaded_ctrlp_quickfix = 1 -let s:var_qf = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#quickfix#init()', \ 'accept': 'ctrlp#quickfix#accept', \ 'lname': 'quickfix', \ 'sname': 'qfx', \ 'type': 'line', \ 'sort': 0, - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:var_qf) : [s:var_qf] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) diff --git a/autoload/ctrlp/rtscript.vim b/autoload/ctrlp/rtscript.vim index b91a4ab..c55889e 100644 --- a/autoload/ctrlp/rtscript.vim +++ b/autoload/ctrlp/rtscript.vim @@ -10,17 +10,14 @@ if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript en let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0] -let s:rtscript_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#rtscript#init()', \ 'accept': 'ctrlp#acceptfile', \ 'lname': 'runtime scripts', \ 'sname': 'rts', \ 'type': 'path', \ 'opmul': 1, - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:rtscript_var) : [s:rtscript_var] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Public {{{1 diff --git a/autoload/ctrlp/tag.vim b/autoload/ctrlp/tag.vim index 1b90b7f..9c07caa 100644 --- a/autoload/ctrlp/tag.vim +++ b/autoload/ctrlp/tag.vim @@ -10,17 +10,14 @@ if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag en let g:loaded_ctrlp_tag = 1 -let s:tag_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#tag#init()', \ 'accept': 'ctrlp#tag#accept', \ 'lname': 'tags', \ 'sname': 'tag', \ 'enter': 'ctrlp#tag#enter()', \ 'type': 'tabs', - \ } - -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] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) " Utilities {{{1 diff --git a/autoload/ctrlp/undo.vim b/autoload/ctrlp/undo.vim index 9f0ef53..871c674 100644 --- a/autoload/ctrlp/undo.vim +++ b/autoload/ctrlp/undo.vim @@ -10,7 +10,7 @@ if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo ) en let g:loaded_ctrlp_undo = 1 -let s:undo_var = { +cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#undo#init()', \ 'accept': 'ctrlp#undo#accept', \ 'lname': 'undo', @@ -19,10 +19,7 @@ let s:undo_var = { \ 'exit': 'ctrlp#undo#exit()', \ 'type': 'line', \ 'sort': 0, - \ } - -let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) - \ ? add(g:ctrlp_ext_vars, s:undo_var) : [s:undo_var] + \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 25aff63..fcfe482 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -145,6 +145,10 @@ only need to keep the lines that you’ve changed the values (inside []): > \ 'PrtClear()': [''], \ 'PrtSelectMove("j")': ['', ''], \ 'PrtSelectMove("k")': ['', ''], + \ 'PrtSelectMove("t")': ['', ''], + \ 'PrtSelectMove("b")': ['', ''], + \ 'PrtSelectMove("u")': ['', ''], + \ 'PrtSelectMove("d")': ['', ''], \ 'PrtHistory(-1)': [''], \ 'PrtHistory(1)': [''], \ 'AcceptSelection("e")': ['', '<2-LeftMouse>'], diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index 6c58d9e..4ac2a7d 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -10,9 +10,9 @@ if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp en let g:loaded_ctrlp = 1 -let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, - \ g:ctrlp_alldirs, g:ctrlp_allmixes, g:ctrlp_buftags, - \ g:ctrlp_builtins] = [[], [], [], [], {}, {}, 2] +let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs, + \ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins] + \ = [[], [], [], [], {}, {}, [], 2] if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en