parent
dbc40ca3be
commit
7cda4083de
82
autoload/ctrlp/mixed.vim
Normal file
82
autoload/ctrlp/mixed.vim
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
" =============================================================================
|
||||||
|
" File: autoload/ctrlp/mixed.vim
|
||||||
|
" Description: Files + MRU
|
||||||
|
" Author: Kien Nguyen <github.com/kien>
|
||||||
|
" =============================================================================
|
||||||
|
|
||||||
|
" Init {{{1
|
||||||
|
if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
|
||||||
|
fini
|
||||||
|
en
|
||||||
|
let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
|
||||||
|
|
||||||
|
let s:mixed_var = {
|
||||||
|
\ 'init': 'ctrlp#mixed#init(s:compare_lim)',
|
||||||
|
\ 'accept': 'ctrlp#acceptfile',
|
||||||
|
\ 'lname': 'fil + mru',
|
||||||
|
\ 'sname': 'mix',
|
||||||
|
\ '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
|
||||||
|
fu! s:newcache(cwd)
|
||||||
|
if !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
|
||||||
|
retu g:ctrlp_allmixes['cwd'] != a:cwd
|
||||||
|
\ || g:ctrlp_allmixes['time'] < getftime(ctrlp#utils#cachefile())
|
||||||
|
\ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#mrufs())
|
||||||
|
endf
|
||||||
|
|
||||||
|
fu! s:getnewmix(cwd, clim)
|
||||||
|
if g:ctrlp_newmix
|
||||||
|
cal ctrlp#mrufiles#refresh('raw')
|
||||||
|
let g:ctrlp_newcache = 1
|
||||||
|
en
|
||||||
|
cal ctrlp#files()
|
||||||
|
cal ctrlp#progress('Mixing...')
|
||||||
|
let mrufs = ctrlp#mrufiles#list('raw')
|
||||||
|
if exists('+ssl') && &ssl
|
||||||
|
cal map(mrufs, 'tr(v:val, "\\", "/")')
|
||||||
|
en
|
||||||
|
if len(mrufs) > len(g:ctrlp_allfiles) || v:version < 702
|
||||||
|
cal filter(mrufs, 'stridx(v:val, a:cwd)')
|
||||||
|
el
|
||||||
|
let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
|
||||||
|
let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
|
||||||
|
for each in cwd_mrufs
|
||||||
|
let id = index(g:ctrlp_allfiles, each)
|
||||||
|
if id >= 0 | cal remove(g:ctrlp_allfiles, id) | en
|
||||||
|
endfo
|
||||||
|
en
|
||||||
|
cal map(mrufs, 'fnamemodify(v:val, ":.")')
|
||||||
|
let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_allfiles)
|
||||||
|
\ ? g:ctrlp_allfiles + mrufs : mrufs + g:ctrlp_allfiles
|
||||||
|
if len(g:ctrlp_lines) <= a:clim
|
||||||
|
cal sort(g:ctrlp_lines, 'ctrlp#complen')
|
||||||
|
en
|
||||||
|
let g:ctrlp_allmixes = { 'time': getftime(ctrlp#utils#cachefile()),
|
||||||
|
\ 'cwd': a:cwd, 'bufs': len(ctrlp#mrufiles#mrufs()), 'data': g:ctrlp_lines }
|
||||||
|
endf
|
||||||
|
" Public {{{1
|
||||||
|
fu! ctrlp#mixed#init(clim)
|
||||||
|
let cwd = getcwd()
|
||||||
|
if g:ctrlp_newmix || s:newcache(cwd)
|
||||||
|
cal s:getnewmix(cwd, a:clim)
|
||||||
|
el
|
||||||
|
let g:ctrlp_lines = g:ctrlp_allmixes['data']
|
||||||
|
en
|
||||||
|
let g:ctrlp_newmix = 0
|
||||||
|
retu g:ctrlp_lines
|
||||||
|
endf
|
||||||
|
|
||||||
|
fu! ctrlp#mixed#id()
|
||||||
|
retu s:id
|
||||||
|
endf
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
@ -64,7 +64,7 @@ fu! s:record(bufnr, ...)
|
|||||||
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||||
endf
|
endf
|
||||||
" Public {{{1
|
" Public {{{1
|
||||||
fu! ctrlp#mrufiles#refresh()
|
fu! ctrlp#mrufiles#refresh(...)
|
||||||
let mrufs = s:readcache()
|
let mrufs = s:readcache()
|
||||||
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
|
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
|
||||||
if exists('+ssl')
|
if exists('+ssl')
|
||||||
@ -72,7 +72,7 @@ fu! ctrlp#mrufiles#refresh()
|
|||||||
cal filter(mrufs, 'count(mrufs, v:val) == 1')
|
cal filter(mrufs, 'count(mrufs, v:val) == 1')
|
||||||
en
|
en
|
||||||
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||||
retu s:reformat(mrufs)
|
retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#mrufiles#remove(files)
|
fu! ctrlp#mrufiles#remove(files)
|
||||||
@ -86,8 +86,8 @@ fu! ctrlp#mrufiles#remove(files)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#mrufiles#list(...)
|
fu! ctrlp#mrufiles#list(...)
|
||||||
if a:0 | cal s:record(a:1) | retu | en
|
if a:0 && a:1 != 'raw' | cal s:record(a:1) | retu | en
|
||||||
retu s:reformat(s:readcache())
|
retu a:0 && a:1 == 'raw' ? s:readcache() : s:reformat(s:readcache())
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#mrufiles#bufs()
|
fu! ctrlp#mrufiles#bufs()
|
||||||
|
@ -696,7 +696,7 @@ 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', 'buffertag', 'quickfix', 'dir', 'rtscript',
|
let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript',
|
||||||
\ 'undo', 'line', 'changes']
|
\ 'undo', 'line', 'changes', 'mixed']
|
||||||
<
|
<
|
||||||
The order of the items will be the order they appear on the statusline and when
|
The order of the items will be the order they appear on the statusline and when
|
||||||
using <c-f>, <c-b>.
|
using <c-f>, <c-b>.
|
||||||
@ -766,6 +766,12 @@ Available extensions:~
|
|||||||
- Search for and jump to a recent change in the current buffer or in all
|
- Search for and jump to a recent change in the current buffer or in all
|
||||||
listed buffers.
|
listed buffers.
|
||||||
|
|
||||||
|
*:CtrlPMixed*
|
||||||
|
* Mixed mode:~
|
||||||
|
- Name: 'mixed'
|
||||||
|
- Command: ':CtrlPMixed'
|
||||||
|
- Search in both files and MRU files.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Buffer Tag mode options:~
|
Buffer Tag mode options:~
|
||||||
|
|
||||||
@ -898,6 +904,8 @@ Special thanks:~
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
CHANGELOG *ctrlp-changelog*
|
CHANGELOG *ctrlp-changelog*
|
||||||
|
|
||||||
|
+ New command: |:CtrlPMixed|, search in both files and MRU files.
|
||||||
|
|
||||||
Before 2012/03/31~
|
Before 2012/03/31~
|
||||||
|
|
||||||
+ New option: |g:ctrlp_default_input|, default input when entering CtrlP.
|
+ New option: |g:ctrlp_default_input|, default input when entering CtrlP.
|
||||||
|
@ -10,8 +10,9 @@ if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
|
|||||||
en
|
en
|
||||||
let g:loaded_ctrlp = 1
|
let g:loaded_ctrlp = 1
|
||||||
|
|
||||||
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
|
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags,
|
||||||
\ g:ctrlp_buftags, g:ctrlp_builtins] = [[], [], [], [], {}, 2]
|
\ g:ctrlp_alldirs, g:ctrlp_allmixes, g:ctrlp_buftags,
|
||||||
|
\ g:ctrlp_builtins] = [[], [], [], [], {}, {}, 2]
|
||||||
|
|
||||||
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
|
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
|
||||||
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
|
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
|
||||||
@ -39,22 +40,17 @@ en
|
|||||||
|
|
||||||
cal ctrlp#mrufiles#init()
|
cal ctrlp#mrufiles#init()
|
||||||
|
|
||||||
com! CtrlPTag cal ctrlp#init(ctrlp#tag#id())
|
com! CtrlPTag cal ctrlp#init(ctrlp#tag#id())
|
||||||
|
com! CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
|
||||||
com! CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
|
com! -n=? -com=dir CtrlPDir
|
||||||
|
\ cal ctrlp#init(ctrlp#dir#id(), <q-args>)
|
||||||
com! -n=? -com=dir CtrlPDir cal ctrlp#init(ctrlp#dir#id(), <q-args>)
|
|
||||||
|
|
||||||
com! -n=? -com=buffer CtrlPBufTag
|
com! -n=? -com=buffer CtrlPBufTag
|
||||||
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
|
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
|
||||||
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
||||||
|
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
||||||
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
|
||||||
|
com! CtrlPLine cal ctrlp#init(ctrlp#line#id())
|
||||||
com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
|
|
||||||
|
|
||||||
com! CtrlPLine cal ctrlp#init(ctrlp#line#id())
|
|
||||||
|
|
||||||
com! -n=? -com=buffer CtrlPChange
|
com! -n=? -com=buffer CtrlPChange
|
||||||
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
|
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
|
||||||
com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
|
com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
|
||||||
|
com! CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user