1
0
Fork 0
mirror of synced 2024-11-22 08:45:34 -05:00

Use ctrlpvim/ctrlp.vim instead of unmaintained kien/ctrlp.vim

This commit is contained in:
Tonni 2016-04-29 23:52:07 +08:00
parent 5f6aa8fe09
commit 5d1fca4b44
13 changed files with 2400 additions and 169 deletions

View file

@ -68,7 +68,7 @@ I recommend reading the docs of these plugins to understand them better. Each of
* [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim
* [ack.vim](https://github.com/mileszs/ack.vim): Vim plugin for the Perl module / CLI script 'ack'
* [ag.vim](https://github.com/rking/ag.vim): A much faster Ack
* [ctrlp.vim](https://github.com/kien/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. In my config it's mapped to `<Ctrl+F>`, because `<Ctrl+P>` is used by YankRing
* [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. In my config it's mapped to `<Ctrl+F>`, because `<Ctrl+P>` is used by YankRing
* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. Includes my own fork which adds syntax highlighting to MRU. This plugin can be opened with `<leader+f>`
* [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf`
* [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object): Defines a new text object representing lines of code at the same indent level. Useful for python/vim scripts

View file

@ -1,6 +0,0 @@
*.markdown
*.zip
note.txt
tags
.hg*
tmp/*

View file

@ -86,9 +86,16 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'status_func': ['s:status', {}],
\ 'tabpage_position': ['s:tabpage', 'ac'],
\ 'use_caching': ['s:caching', 1],
\ 'use_migemo': ['s:migemo', 0],
\ 'user_command': ['s:usrcmd', ''],
\ 'validate': ['s:validate', ''],
\ 'working_path_mode': ['s:pathmode', 'ra'],
\ 'line_prefix': ['s:lineprefix', '> '],
\ 'open_single_match': ['s:opensingle', []],
\ 'brief_prompt': ['s:brfprt', 0],
\ 'match_current_file': ['s:matchcrfile', 0],
\ 'compare_lim': ['s:compare_lim', 3000],
\ 'bufname_mod': ['s:bufname_mod', ':t'],
\ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'],
\ }, {
\ 'open_multiple_files': 's:opmul',
\ 'regexp': 's:regexp',
@ -148,8 +155,6 @@ if !has('gui_running')
cal add(s:prtmaps['PrtBS()'], remove(s:prtmaps['PrtCurLeft()'], 0))
en
let s:compare_lim = 3000
let s:ficounts = {}
let s:ccex = s:pref.'clear_cache_on_exit'
@ -162,6 +167,9 @@ let s:fpats = {
\ '^\S\\?$': '\\?',
\ }
let s:has_conceal = has('conceal')
let s:bufnr_width = 3
" Keypad
let s:kprange = {
\ 'Plus': '+',
@ -181,7 +189,24 @@ let s:hlgrps = {
\ 'PrtBase': 'Comment',
\ 'PrtText': 'Normal',
\ 'PrtCursor': 'Constant',
\ 'BufferNr': 'Constant',
\ 'BufferInd': 'Normal',
\ 'BufferHid': 'Comment',
\ 'BufferHidMod': 'String',
\ 'BufferVis': 'Normal',
\ 'BufferVisMod': 'Identifier',
\ 'BufferCur': 'Question',
\ 'BufferCurMod': 'WarningMsg',
\ 'BufferPath': 'Comment',
\ }
" lname, sname of the basic(non-extension) modes
let s:coretypes = [
\ ['files', 'fil'],
\ ['buffers', 'buf'],
\ ['mru files', 'mru'],
\ ]
" Get the options {{{2
fu! s:opts(...)
unl! s:usrign s:usrcmd s:urprtmaps
@ -219,6 +244,7 @@ fu! s:opts(...)
for each in ['byfname', 'regexp'] | if exists(each)
let s:{each} = {each}
en | endfo
if !exists('g:ctrlp_tilde_homedir') | let g:ctrlp_tilde_homedir = 0 | en
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
let s:maxdepth = min([s:maxdepth, 100])
let s:glob = s:showhidden ? '.*\|*' : '*'
@ -283,7 +309,8 @@ fu! s:Open()
sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va)
en | endfo
if s:opmul != '0' && has('signs')
sign define ctrlpmark text=+> texthl=Search
sign define ctrlpmark text=+> texthl=CtrlPMark
hi def link CtrlPMark Search
en
cal s:setupblank()
endf
@ -305,7 +332,7 @@ fu! s:Close()
if s:winres[1] >= &lines && s:winres[2] == winnr('$')
exe s:winres[0].s:winres[0]
en
unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:init s:savestr
\ s:mrbs s:did_exp
cal ctrlp#recordhist()
cal s:execextvar('exit')
@ -343,7 +370,9 @@ fu! ctrlp#files()
" Get the list of files
if empty(lscmd)
if !ctrlp#igncwd(s:dyncwd)
cal s:InitCustomFuncs()
cal s:GlobPath(s:fnesc(s:dyncwd, 'g', ','), 0)
cal s:CloseCustomFuncs()
en
el
sil! cal ctrlp#progress('Indexing...')
@ -369,6 +398,18 @@ fu! ctrlp#files()
retu g:ctrlp_allfiles
endf
fu! s:InitCustomFuncs()
if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != ''
exe call(s:usrign['func-init'], [])
en
endf
fu! s:CloseCustomFuncs()
if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != ''
exe call(s:usrign['func-close'], [])
en
endf
fu! s:GlobPath(dirs, depth)
let entries = split(globpath(a:dirs, s:glob), "\n")
let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
@ -387,11 +428,18 @@ fu! s:UserCmd(lscmd)
if exists('+ssl') && &ssl
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
en
if has('win32') || has('win64')
if (has('win32') || has('win64')) && match(&shellcmdflag, "/") != -1
let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
en
let path = exists('*shellescape') ? shellescape(path) : path
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
if (has('win32') || has('win64')) && match(&shell, 'sh') != -1
let path = tr(path, '\', '/')
en
if has('patch-7.4-597') && !(has('win32') || has('win64'))
let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
else
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
end
if exists('+ssl') && exists('ssl')
let &ssl = ssl
cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")')
@ -439,9 +487,27 @@ fu! s:lsCmd()
en
endf
" - Buffers {{{1
fu! s:bufparts(bufnr)
let idc = (a:bufnr == bufnr('#') ? '#' : '') " alternative
let idc .= (getbufvar(a:bufnr, '&mod') ? '+' : '') " modified
let idc .= (getbufvar(a:bufnr, '&ma') ? '' : '-') " nomodifiable
let idc .= (getbufvar(a:bufnr, '&ro') ? '=' : '') " readonly
" flags for highlighting
let hiflags = (bufwinnr(a:bufnr) != -1 ? '*' : '') " visible
let hiflags .= (getbufvar(a:bufnr, '&mod') ? '+' : '') " modified
let hiflags .= (a:bufnr == s:crbufnr ? '!' : '') " current
let bname = bufname(a:bufnr)
let bname = (bname == '' ? '[No Name]' : fnamemodify(bname, s:bufname_mod))
let bpath = empty(s:bufpath_mod) ? '' : fnamemodify(bufname(a:bufnr), s:bufpath_mod).s:lash()
retu [idc, hiflags, bname, bpath]
endf
fu! ctrlp#buffers(...)
let ids = sort(filter(range(1, bufnr('$')), 'empty(getbufvar(v:val, "&bt"))'
\ .' && getbufvar(v:val, "&bl")'), 's:compmreb')
let ids = sort(filter(range(1, bufnr('$')), '(empty(getbufvar(v:val, "&bt"))'
\ .' || s:isneovimterminal(v:val)) && getbufvar(v:val, "&bl")'), 's:compmreb')
if a:0 && a:1 == 'id'
retu ids
el
@ -463,9 +529,12 @@ fu! s:MatchIt(items, pat, limit, exc)
\ : s:martcs.a:pat
for item in a:items
let id += 1
try | if !( s:ispath && item == a:exc ) && call(s:mfunc, [item, pat]) >= 0
cal add(lines, item)
en | cat | brea | endt
try
if (s:matchcrfile || !( s:ispath && item == a:exc )) &&
\call(s:mfunc, [item, pat]) >= 0
cal add(lines, item)
en
cat | brea | endt
if a:limit > 0 && len(lines) >= a:limit | brea | en
endfo
let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)]
@ -497,9 +566,6 @@ endf
fu! s:SplitPattern(str)
let str = a:str
if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo')
let str = s:migemo(str)
en
let s:savestr = str
if s:regexp
let pat = s:regexfilter(str)
@ -533,6 +599,7 @@ fu! s:Render(lines, pat)
let height = min([max([s:mw_min, s:res_count]), s:winmaxh])
let pat = s:byfname() ? split(a:pat, '^[^;]\+\\\@<!\zs;', 1)[0] : a:pat
let cur_cmd = 'keepj norm! '.( s:mw_order == 'btt' ? 'G' : 'gg' ).'1|'
" Setup the match window
sil! exe '%d _ | res' height
" Print the new items
@ -557,17 +624,14 @@ fu! s:Render(lines, pat)
let s:lines = copy(lines)
cal map(lines, 's:formatline(v:val)')
cal setline(1, s:offset(lines, height))
setl noma cul
exe cur_cmd
cal s:unmarksigns()
cal s:remarksigns()
if exists('s:cline') && s:nolim != 1
cal cursor(s:cline, 1)
en
" Highlighting
if s:dohighlight()
cal s:highlight(pat, s:mathi[1])
en
setl noma cul
exe cur_cmd
endf
fu! s:Update(str)
@ -577,15 +641,21 @@ fu! s:Update(str)
let str = s:sanstail(a:str)
" Stop if the string's unchanged
if str == oldstr && !empty(str) && !exists('s:force') | retu | en
" Optionally send the string to a custom validate function
if s:validate != '' | let str = call(s:validate, [str]) | en
let s:martcs = &scs && str =~ '\u' ? '\C' : ''
let pat = s:matcher == {} ? s:SplitPattern(str) : str
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
if empty(str) | call clearmatches() | en
cal s:Render(lines, pat)
return lines
endf
fu! s:ForceUpdate()
let wv = winsaveview()
sil! cal s:Update(escape(s:getinput(), '\'))
cal winrestview(wv)
endf
fu! s:BuildPrompt(upd)
@ -644,6 +714,10 @@ endf
fu! s:PrtBS()
if !s:focus | retu | en
if empty(s:prompt[0]) && s:brfprt != 0
cal s:PrtExit()
retu
endif
unl! s:hstgot
let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1]
cal s:BuildPrompt(1)
@ -765,8 +839,9 @@ fu! s:PrtSelectMove(dir)
let wht = winheight(0)
let dirs = {'t': 'gg','b': 'G','j': 'j','k': 'k','u': wht.'k','d': wht.'j'}
exe 'keepj norm!' dirs[a:dir]
if s:nolim != 1 | let s:cline = line('.') | en
if line('$') > winheight(0) | cal s:BuildPrompt(0) | en
let wv = winsaveview()
cal s:BuildPrompt(0)
cal winrestview(wv)
endf
fu! s:PrtSelectJump(char)
@ -789,8 +864,9 @@ fu! s:PrtSelectJump(char)
let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]]
en
exe 'keepj norm!' ( jmpln + 1 ).'G'
if s:nolim != 1 | let s:cline = line('.') | en
if line('$') > winheight(0) | cal s:BuildPrompt(0) | en
let wv = winsaveview()
cal s:BuildPrompt(0)
cal winrestview(wv)
en
endf
" Misc {{{2
@ -817,6 +893,8 @@ endf
fu! s:PrtDeleteEnt()
if s:itemtype == 2
cal s:PrtDeleteMRU()
elsei s:itemtype == 1
cal s:delbuf()
elsei type(s:getextvar('wipe')) == 1
cal s:delent(s:getextvar('wipe'))
en
@ -875,7 +953,7 @@ fu! s:MapSpecs()
if !( exists('s:smapped') && s:smapped == s:bufnr )
" Correct arrow keys in terminal
if ( has('termresponse') && v:termresponse =~ "\<ESC>" )
\ || &term =~? '\vxterm|<k?vt|gnome|screen|linux|ansi'
\ || &term =~? '\vxterm|<k?vt|gnome|screen|linux|ansi|tmux|st(-[-a-z0-9]*)?$'
for each in ['\A <up>','\B <down>','\C <right>','\D <left>']
exe s:lcmap.' <esc>['.each
endfo
@ -888,15 +966,25 @@ fu! s:MapSpecs()
endf
fu! s:KeyLoop()
let [t_ve, guicursor] = [&t_ve, &guicursor]
wh exists('s:init') && s:keyloop
redr
let nr = getchar()
try
set t_ve=
set guicursor=a:NONE
let nr = getchar()
fina
let &t_ve = t_ve
let &guicursor = guicursor
endt
let chr = !type(nr) ? nr2char(nr) : nr
if nr >=# 0x20
cal s:PrtFocusMap(chr)
el
let cmd = matchstr(maparg(chr), ':<C-U>\zs.\+\ze<CR>$')
exe ( cmd != '' ? cmd : 'norm '.chr )
try
exe ( cmd != '' ? cmd : 'norm '.chr )
cat
endt
en
endw
endf
@ -922,8 +1010,8 @@ endf
fu! s:ToggleType(dir)
let max = len(g:ctrlp_ext_vars) + 2
let next = s:walker(max, s:itemtype, a:dir)
cal ctrlp#syntax()
cal ctrlp#setlines(next)
cal ctrlp#syntax()
cal s:PrtSwitcher()
endf
@ -959,23 +1047,19 @@ fu! s:SetWD(args)
if has_key(a:args, 'dir') && a:args['dir'] != ''
cal ctrlp#setdir(a:args['dir']) | retu
en
let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
let pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
if s:crfile =~ '^.\+://' | retu | en
if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
\ || ( !type(pmode) && pmode )
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
cal ctrlp#setdir(s:crfpath)
en
if pmode =~ 'r' || pmode == 2
let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en
cal filter(markers, 'index(s:rmarkers, v:val) < 0')
en
cal s:findroot(spath, markers, 0, 0)
if (!type(pmodes))
let pmodes =
\ pmodes == 0 ? '' :
\ pmodes == 1 ? 'a' :
\ pmodes == 2 ? 'r' :
\ 'c'
en
let spath = pmodes =~ 'd' ? s:dyncwd : pmodes =~ 'w' ? s:cwd : s:crfpath
for pmode in split(pmodes, '\zs')
if ctrlp#setpathmode(pmode, spath) | retu | en
endfo
endf
" * AcceptSelection() {{{1
fu! ctrlp#acceptfile(...)
@ -990,18 +1074,15 @@ fu! ctrlp#acceptfile(...)
if !type(line)
let [filpath, bufnr, useb] = [line, line, 1]
el
let filpath = fnamemodify(line, ':p')
if s:nonamecond(line, filpath)
let bufnr = str2nr(matchstr(line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
let [filpath, useb] = [bufnr, 1]
el
let bufnr = bufnr('^'.filpath.'$')
let [bufnr, filpath] = s:bufnrfilpath(line)
if bufnr == filpath
let useb = 1
en
en
cal s:PrtExit()
let tail = s:tail()
let j2l = atl != '' ? atl : matchstr(tail, '^ +\zs\d\+$')
if ( s:jmptobuf =~ md || ( s:jmptobuf && md =~ '[et]' ) ) && bufnr > 0
if bufnr > 0 && ( !empty(s:jmptobuf) && s:jmptobuf =~ md )
\ && !( md == 'e' && bufnr == bufnr('%') )
let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
let buftab = ( s:jmptobuf =~# '[tTVH]' || s:jmptobuf > 1 )
@ -1127,6 +1208,13 @@ fu! s:MarkToOpen()
retu
en
let line = ctrlp#getcline()
" Do not allow to mark modified or current buffer
let bufnr = s:bufnrfilpath(line)[0]
if (s:itemtype == 1 && s:delbufcond(bufnr))
retu
en
if empty(line) | retu | en
let filpath = s:ispath ? fnamemodify(line, ':p') : line
if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
@ -1283,7 +1371,16 @@ endf
fu! s:compmreb(...)
" By last entered time (bufnr)
let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)]
retu id1 == id2 ? 0 : id1 > id2 ? 1 : -1
if id1 == id2
return 0
endif
if id1 < 0
return 1
endif
if id2 < 0
return -1
endif
return id1 > id2 ? 1 : -1
endf
fu! s:compmref(...)
@ -1369,11 +1466,7 @@ endf
" Statusline {{{2
fu! ctrlp#statusline()
if !exists('s:statypes')
let s:statypes = [
\ ['files', 'fil'],
\ ['buffers', 'buf'],
\ ['mru files', 'mru'],
\ ]
let s:statypes = copy(s:coretypes)
if !empty(g:ctrlp_ext_vars)
cal map(copy(g:ctrlp_ext_vars),
\ 'add(s:statypes, [ v:val["lname"], v:val["sname"] ])')
@ -1433,18 +1526,27 @@ endf
fu! s:formatline(str)
let str = a:str
if s:itemtype == 1
let filpath = fnamemodify(str, ':p')
let bufnr = s:nonamecond(str, filpath)
\ ? str2nr(matchstr(str, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
\ : bufnr('^'.filpath.'$')
let idc = ( bufnr == bufnr('#') ? '#' : '' )
\ . ( getbufvar(bufnr, '&ma') ? '' : '-' )
\ . ( getbufvar(bufnr, '&ro') ? '=' : '' )
\ . ( getbufvar(bufnr, '&mod') ? '+' : '' )
let str .= idc != '' ? ' '.idc : ''
let bufnr = s:bufnrfilpath(str)[0]
let parts = s:bufparts(bufnr)
let str = printf('%'.s:bufnr_width.'s', bufnr)
if s:has_conceal
let str .= printf(' %-13s %s%-36s',
\ '<bi>'.parts[0].'</bi>',
\ '<bn>'.parts[1], '{'.parts[2].'}</bn>')
if (!empty(s:bufpath_mod))
let str .= printf(' %s', '<bp>'.parts[3].'</bp>')
en
el
let str .= printf(' %-5s %-30s %s',
\ parts[0],
\ parts[2])
if (!empty(s:bufpath_mod))
let str .= printf(' %s', parts[3])
en
en
en
let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(str)
retu '> '.( cond ? s:pathshorten(str) : str )
let cond = s:itemtype != 1 &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
retu s:lineprefix.( cond ? s:pathshorten(str) : str )
endf
fu! s:pathshorten(str)
@ -1532,9 +1634,21 @@ fu! ctrlp#dirnfile(entries)
endf
fu! s:usrign(item, type)
retu s:igntype == 1 ? a:item =~ s:usrign
\ : s:igntype == 4 && has_key(s:usrign, a:type) && s:usrign[a:type] != ''
\ ? a:item =~ s:usrign[a:type] : 0
if s:igntype == 1 | retu a:item =~ s:usrign | end
if s:igntype == 2
if call(s:usrign, [a:item, a:type])
retu 1
end
elsei s:igntype == 4
if has_key(s:usrign, a:type) && s:usrign[a:type] != ''
\ && a:item =~ s:usrign[a:type]
retu 1
elsei has_key(s:usrign, 'func') && s:usrign['func'] != ''
\ && call(s:usrign['func'], [a:item, a:type])
retu 1
end
end
retu 0
endf
fu! s:samerootsyml(each, isfile, cwd)
@ -1544,8 +1658,16 @@ fu! s:samerootsyml(each, isfile, cwd)
endf
fu! ctrlp#rmbasedir(items)
if a:items == []
retu a:items
en
let cwd = s:dyncwd.s:lash()
if a:items != [] && !stridx(a:items[0], cwd)
let first = a:items[0]
if has('win32') || has('win64')
let cwd = tr(cwd, '\', '/')
let first = tr(first, '\', '/')
en
if !stridx(first, cwd)
let idx = strlen(cwd)
retu map(a:items, 'strpart(v:val, idx)')
en
@ -1586,6 +1708,23 @@ fu! s:findroot(curr, mark, depth, type)
retu []
endf
fu! ctrlp#setpathmode(pmode, ...)
if a:pmode == 'c' || ( a:pmode == 'a' && stridx(s:crfpath, s:cwd) < 0 )
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
cal ctrlp#setdir(s:crfpath)
retu 1
elsei a:pmode == 'r'
let spath = a:0 ? a:1 : s:crfpath
let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
cal filter(markers, 'index(s:rmarkers, v:val) < 0')
let markers = s:rmarkers + markers
en
if s:findroot(spath, markers, 0, 0) != [] | retu 1 | en
en
retu 0
endf
fu! ctrlp#setdir(path, ...)
let cmd = a:0 ? a:1 : 'lc!'
sil! exe cmd s:fnesc(a:path, 'c')
@ -1609,25 +1748,83 @@ endf
fu! ctrlp#syntax()
if ctrlp#nosy() | retu | en
for [ke, va] in items(s:hlgrps) | cal ctrlp#hicheck('CtrlP'.ke, va) | endfo
if synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$'
sil! exe 'hi CtrlPLinePre '.( has("gui_running") ? 'gui' : 'cterm' ).'fg=bg'
let bgColor=synIDattr(synIDtrans(hlID('Normal')), 'bg')
if bgColor !~ '^-1$\|^$'
sil! exe 'hi CtrlPLinePre guifg='.bgColor.' ctermfg='.bgColor
en
sy match CtrlPNoEntries '^ == NO ENTRIES ==$'
if hlexists('CtrlPLinePre')
sy match CtrlPLinePre '^>'
en
if s:itemtype == 1 && s:has_conceal
sy region CtrlPBufferNr matchgroup=CtrlPLinePre start='^>\s\+' end='\s'
sy region CtrlPBufferInd concealends matchgroup=Ignore start='<bi>' end='</bi>'
sy region CtrlPBufferRegion concealends matchgroup=Ignore start='<bn>' end='</bn>'
\ contains=CtrlPBufferHid,CtrlPBufferHidMod,CtrlPBufferVis,CtrlPBufferVisMod,CtrlPBufferCur,CtrlPBufferCurMod
sy region CtrlPBufferHid concealends matchgroup=Ignore start='\s*{' end='}' contained
sy region CtrlPBufferHidMod concealends matchgroup=Ignore start='+\s*{' end='}' contained
sy region CtrlPBufferVis concealends matchgroup=Ignore start='\*\s*{' end='}' contained
sy region CtrlPBufferVisMod concealends matchgroup=Ignore start='\*+\s*{' end='}' contained
sy region CtrlPBufferCur concealends matchgroup=Ignore start='\*!\s*{' end='}' contained
sy region CtrlPBufferCurMod concealends matchgroup=Ignore start='\*+!\s*{' end='}' contained
sy region CtrlPBufferPath concealends matchgroup=Ignore start='<bp>' end='</bp>'
en
endf
fu! s:highlight(pat, grp)
if s:matcher != {} | retu | en
cal clearmatches()
if !empty(a:pat) && s:ispath
let pat = s:regexp ? substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g') : a:pat
if s:byfname
let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g')
let pat = substitute(pat, '\$\@<!$', '\\ze[^\\/]*$', 'g')
if s:regexp
let pat = substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g')
cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat)
el
let pat = a:pat
" get original characters so we can rebuild pat
let chars = split(pat, '\[\^\\\?.\]\\{-}')
" Build a pattern like /a.*b.*c/ from abc (but with .\{-} non-greedy
" matchers instead)
let pat = join(chars, '.\{-}')
" Ensure we match the last version of our pattern
let ending = '\(.*'.pat.'\)\@!'
" Case sensitive?
let beginning = ( s:martcs == '' ? '\c' : '\C' ).'^.*'
if s:byfname()
" Make sure there are no slashes in our match
let beginning = beginning.'\([^\/]*$\)\@='
end
for i in range(len(chars))
" Surround our current target letter with \zs and \ze so it only
" actually matches that one letter, but has all preceding and trailing
" letters as well.
" \zsa.*b.*c
" a\(\zsb\|.*\zsb)\ze.*c
let charcopy = copy(chars)
if i == 0
let charcopy[i] = '\zs'.charcopy[i].'\ze'
let middle = join(charcopy, '.\{-}')
else
let before = join(charcopy[0:i-1], '.\{-}')
let after = join(charcopy[i+1:-1], '.\{-}')
let c = charcopy[i]
" for abc, match either ab.\{-}c or a.*b.\{-}c in that order
let cpat = '\(\zs'.c.'\|'.'.*\zs'.c.'\)\ze.*'
let middle = before.cpat.after
endif
" Now we matchadd for each letter, the basic form being:
" ^.*\zsx\ze.*$, but with our pattern we built above for the letter,
" and a negative lookahead ensuring that we only highlight the last
" occurrence of our letters. We also ensure that our matcher is case
" insensitive or sensitive depending.
cal matchadd(a:grp, beginning.middle.ending)
endfor
en
cal matchadd(a:grp, ( s:martcs == '' ? '\c' : '\C' ).pat)
cal matchadd('CtrlPLinePre', '^>')
en
endf
@ -1735,15 +1932,33 @@ fu! s:bufwins(bufnr)
retu winns
endf
fu! s:nonamecond(str, filpath)
retu a:str =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(a:filpath)
\ && bufnr('^'.a:filpath.'$') < 1
fu! s:isabs(path)
if (has('win32') || has('win64'))
return a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]'
el
return a:path =~ '^[/\\]'
en
endf
fu! s:bufnrfilpath(line)
if s:isabs(a:line) || a:line =~ '^\~[/\\]'
let filpath = a:line
el
let filpath = s:dyncwd.s:lash().a:line
en
let filpath = fnamemodify(filpath, ':p')
let bufnr = bufnr('^'.filpath.'$')
if (a:line =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(filpath) && bufnr < 1)
let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
let filpath = bufnr
en
retu [bufnr, filpath]
endf
fu! ctrlp#normcmd(cmd, ...)
if a:0 < 2 && s:nosplit() | retu a:cmd | en
let norwins = filter(range(1, winnr('$')),
\ 'empty(getbufvar(winbufnr(v:val), "&bt"))')
\ 'empty(getbufvar(winbufnr(v:val), "&bt")) || s:isneovimterminal(winbufnr(v:val))')
for each in norwins
let bufnr = winbufnr(each)
if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
@ -1775,6 +1990,9 @@ fu! s:setupblank()
if v:version > 702
setl nornu noudf cc=0
en
if s:has_conceal
setl cole=2 cocu=nc
en
endf
fu! s:leavepre()
@ -1911,7 +2129,7 @@ fu! s:nosort()
endf
fu! s:byfname()
retu s:ispath && s:byfname
retu s:itemtype != 1 && s:ispath && s:byfname
endf
fu! s:narrowable()
@ -1946,22 +2164,6 @@ fu! s:getinput(...)
retu spi == 'c' ? prt[0] : join(prt, '')
endf
fu! s:migemo(str)
let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')]
let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1)
if !len(dict)
let dict = s:glbpath(rtp, "dict/migemo-dict", 1)
en
if len(dict)
let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s']
for token in tokens
let rtn = system(printf(cmd, shellescape(token), shellescape(dict)))
let str .= !v:shell_error && strlen(rtn) > 0 ? '.*'.rtn : token
endfo
en
retu str
endf
fu! s:strwidth(str)
retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str)
endf
@ -2005,6 +2207,33 @@ fu! s:delent(rfunc)
cal s:BuildPrompt(1)
unl s:force
endf
fu! s:delbufcond(bufnr)
retu getbufvar(a:bufnr, "&mod") || a:bufnr == s:crbufnr
endf
fu! s:delbuf()
let lines = []
if exists('s:marked')
let lines = values(s:marked)
cal s:unmarksigns()
unl s:marked
el
let lines += [ctrlp#getcline()]
en
for line in lines
let bufnr = s:bufnrfilpath(line)[0]
if (s:delbufcond(bufnr))
con
en
exe 'bd '. bufnr
endfo
cal s:PrtClearCache()
endf
fu! s:isneovimterminal(buf)
retu has('nvim') && getbufvar(a:buf, "&bt") == "terminal"
endf
" Entering & Exiting {{{2
fu! s:getenv()
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
@ -2097,7 +2326,13 @@ fu! s:matchfname(item, pat)
retu len(a:pat) == 1 ? mfn : len(a:pat) == 2 ?
\ ( mfn >= 0 && ( len(parts) == 2 ? match(parts[0], a:pat[1]) : -1 ) >= 0
\ ? 0 : -1 ) : -1
en
endf
fu! s:matchbuf(item, pat)
let bufnr = s:bufnrfilpath(a:item)[0]
let parts = s:bufparts(bufnr)
let item = bufnr.parts[0].parts[2].s:lash().parts[3]
retu match(item, a:pat)
endf
fu! s:matchtabs(item, pat)
@ -2120,6 +2355,8 @@ fu! s:mfunc()
let mfunc = 'match'
if s:byfname()
let mfunc = 's:matchfname'
elsei s:itemtype == 1
let mfunc = 's:matchbuf'
elsei s:itemtype > 2
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
if has_key(matchtypes, s:matchtype)
@ -2133,6 +2370,7 @@ fu! s:mmode()
let matchmodes = {
\ 'match': 'full-line',
\ 's:matchfname': 'filename-only',
\ 's:matchbuf': 'full-line',
\ 's:matchtabs': 'first-non-tab',
\ 's:matchtabe': 'until-last-tab',
\ }
@ -2193,7 +2431,7 @@ fu! s:getextvar(key)
let vars = g:ctrlp_ext_vars[s:itemtype - 3]
retu has_key(vars, a:key) ? vars[a:key] : -1
en
retu -1
retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1)
endf
fu! ctrlp#getcline()
@ -2206,6 +2444,10 @@ fu! ctrlp#getmarkedlist()
retu exists('s:marked') ? values(s:marked) : []
endf
fu! ctrlp#clearmarkedlist()
let s:marked = {}
endf
fu! ctrlp#exit()
cal s:PrtExit()
endf
@ -2247,6 +2489,24 @@ fu! ctrlp#setlines(...)
let g:ctrlp_lines = eval(types[s:itemtype])
endf
" Returns [lname, sname]
fu! s:CurTypeName()
if s:itemtype < 3
return s:coretypes[s:itemtype]
else
return [s:getextvar("lname"), s:getextvar('sname')]
endif
endfu
fu! s:ExitIfSingleCandidate()
if len(s:Update(s:prompt[0])) == 1
call s:AcceptSelection('e')
call ctrlp#exit()
return 1
endif
return 0
endfu
fu! ctrlp#init(type, ...)
if exists('s:init') || s:iscmdwin() | retu | en
let [s:ermsg, v:errmsg] = [v:errmsg, '']
@ -2256,11 +2516,17 @@ fu! ctrlp#init(type, ...)
cal s:SetWD(a:0 ? a:1 : {})
cal s:MapNorms()
cal s:MapSpecs()
cal ctrlp#syntax()
cal ctrlp#setlines(s:settype(a:type))
cal ctrlp#syntax()
cal s:SetDefTxt()
let curName = s:CurTypeName()
let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0
if shouldExitSingle && s:ExitIfSingleCandidate()
return 0
endif
cal s:BuildPrompt(1)
if s:keyloop | cal s:KeyLoop() | en
return 1
endf
" - Autocmds {{{1
if has('autocmd')

View file

@ -0,0 +1,173 @@
" =============================================================================
" File: autoload/ctrlp/autoignore.vim
" Description: Auto-ignore Extension
" Author: Ludovic Chabant <github.com/ludovicchabant>
" =============================================================================
" Global Settings {{{
if exists('g:ctrlp_autoignore_loaded') && g:ctrlp_autoignore_loaded
\ && !g:ctrlp_autoignore_debug
finish
endif
let g:ctrlp_autoignore_loaded = 1
if !exists('g:ctrlp_autoignore_debug')
let g:ctrlp_autoignore_debug = 0
endif
if !exists('g:ctrlp_autoignore_trace')
let g:ctrlp_autoignore_trace = 0
endif
" }}}
" Initialization {{{
if !exists('g:ctrlp_custom_ignore')
let g:ctrlp_custom_ignore = {}
endif
let g:ctrlp_custom_ignore['func'] = 'ctrlp#autoignore#ignore'
let g:ctrlp_custom_ignore['func-init'] = 'ctrlp#autoignore#ignore_init'
let g:ctrlp_custom_ignore['func-close'] = 'ctrlp#autoignore#ignore_close'
if !exists('g:ctrlp_root_markers')
let g:ctrlp_root_markers = []
endif
call add(g:ctrlp_root_markers, '.ctrlpignore')
" }}}
" Internals {{{
function! s:trace(message) abort
if g:ctrlp_autoignore_trace
echom "ctrlp_autoignore: " . a:message
endif
endfunction
let s:proj_cache = {}
let s:active_cwd = ''
let s:active_cwd_len = 0
let s:active_patterns = []
let s:changed_wildignore = 0
let s:prev_wildignore = ''
function! s:load_project_patterns(root_dir) abort
let l:ign_path = a:root_dir . '/.ctrlpignore'
if !filereadable(l:ign_path)
call s:trace("No pattern file at: " . l:ign_path)
return []
endif
let l:cursyntax = 'regexp'
let l:knownsyntaxes = ['regexp', 'wildignore']
let l:patterns = []
let l:lines = readfile(l:ign_path)
for line in l:lines
" Comment line?
if match(line, '\v^\s*$') >= 0 || match(line, '\v^\s*#') >= 0
continue
endif
" Syntax change?
let l:matches = matchlist(line, '\v^syntax:\s?(\w+)\s*$')
if len(l:matches) > 0
let l:cursyntax = l:matches[1]
if index(l:knownsyntaxes, l:cursyntax) < 0
echoerr "ctrlp_autoignore: Unknown syntax '".l:cursyntax."' in: ".l:ign_path
endif
continue
endif
" Patterns!
let l:matches = matchlist(line, '\v^((dir|file|link)\:)?(.*)')
let l:mtype = l:matches[2]
let l:mpat = l:matches[3]
call add(l:patterns, {'syn': l:cursyntax, 'type': l:mtype, 'pat': l:mpat})
endfor
call s:trace("Loaded " . len(l:patterns) . " patterns from: " . l:ign_path)
return l:patterns
endfunction
function! s:get_project_patterns(root_dir) abort
let l:ign_path = a:root_dir . '/.ctrlpignore'
let l:ign_mtime = getftime(l:ign_path)
let l:patterns = get(s:proj_cache, a:root_dir)
if type(l:patterns) == type({})
" Check that these patterns are still valid.
if l:ign_mtime < 0
" File got deleted! :(
let l:patterns['pats'] = []
return l:patterns['pats']
elseif l:ign_mtime <= l:patterns['mtime']
" File hasn't changed! :)
return l:patterns['pats']
endif
endif
call s:trace("Loading patterns for project: " . a:root_dir)
let l:loaded = s:load_project_patterns(a:root_dir)
let s:proj_cache[a:root_dir] = {
\'mtime': localtime(),
\'pats': l:loaded}
return l:loaded
endfunction
" The custom ignore function that CtrlP will be using in addition to
" normal pattern-based matching.
function! ctrlp#autoignore#ignore(item, type) abort
let l:cnv_item = tr(strpart(a:item, s:active_cwd_len), "\\", "/")
for pat in s:active_patterns
if pat['syn'] != 'regexp'
continue
endif
if pat['type'] == '' || pat['type'] == a:type
if match(l:cnv_item, pat['pat']) >= 0
call s:trace("Ignoring ".l:cnv_item." because of ".pat['pat'])
return 1
endif
endif
endfor
return 0
endfunction
function! ctrlp#autoignore#ignore_init() abort
let l:root = getcwd()
let s:active_cwd = l:root
" len+1 is for including the next separator after the root.
let s:active_cwd_len = len(l:root) + 1
let s:active_patterns = s:get_project_patterns(l:root)
call s:trace("Got ".len(s:active_patterns)." patterns for ".l:root)
let s:changed_wildignore = 0
let s:prev_wildignore = &wildignore
for pat in s:active_patterns
if pat['syn'] == 'wildignore'
execute 'set wildignore+='.pat['pat']
let s:changed_wildignore = 1
endif
endfor
if s:changed_wildignore
call s:trace("Set wildignore to ".&wildignore)
endif
endfunction
function! ctrlp#autoignore#ignore_close() abort
if s:changed_wildignore
execute 'set wildignore='.s:prev_wildignore
let s:prev_wildignore = ''
call s:trace("Set wildignore back to ".&wildignore)
endif
endfunction
" List patterns for a given project's root.
function! ctrlp#autoignore#get_patterns(root_dir) abort
let l:patterns = s:get_project_patterns(a:root_dir)
for pat in l:patterns
let l:prefix = pat['type'] == '' ? '(all)' : pat['type']
echom l:prefix . ':' . pat['pat']
endfor
endfunction
" }}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View file

@ -112,13 +112,20 @@ fu! ctrlp#bookmarkdir#accept(mode, str)
en
endf
fu! ctrlp#bookmarkdir#add(dir, ...)
let str = 'Directory to bookmark: '
let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
if cwd == '' | retu | en
let cwd = fnamemodify(cwd, ':p')
let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
fu! ctrlp#bookmarkdir#add(bang, dir, ...)
let ctrlp_tilde_homedir = get(g:, 'ctrlp_tilde_homedir', 0)
let cwd = fnamemodify(getcwd(), ctrlp_tilde_homedir ? ':p:~' : ':p')
let dir = fnamemodify(a:dir, ctrlp_tilde_homedir ? ':p:~' : ':p')
if a:bang == '!'
let cwd = dir != '' ? dir : cwd
let name = a:0 && a:1 != '' ? a:1 : cwd
el
let str = 'Directory to bookmark: '
let cwd = dir != '' ? dir : s:getinput(str, cwd, 'dir')
if cwd == '' | retu | en
let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
en
let name = tr(name, ' ', ' ')
cal s:savebookmark(name, cwd)
cal s:msg(name, cwd)

View file

@ -43,6 +43,7 @@ let s:bins = [
\ ]
let s:types = {
\ 'ant' : '%sant%sant%spt',
\ 'asm' : '%sasm%sasm%sdlmt',
\ 'aspperl': '%sasp%sasp%sfsv',
\ 'aspvbs' : '%sasp%sasp%sfsv',
@ -52,6 +53,8 @@ let s:types = {
\ 'cpp' : '%sc++%sc++%snvdtcgsuf',
\ 'cs' : '%sc#%sc#%sdtncEgsipm',
\ 'cobol' : '%scobol%scobol%sdfgpPs',
\ 'delphi' : '%spascal%spascal%sfp',
\ 'dosbatch': '%sdosbatch%sdosbatch%slv',
\ 'eiffel' : '%seiffel%seiffel%scf',
\ 'erlang' : '%serlang%serlang%sdrmf',
\ 'expect' : '%stcl%stcl%scfp',
@ -62,6 +65,7 @@ let s:types = {
\ 'lisp' : '%slisp%slisp%sf',
\ 'lua' : '%slua%slua%sf',
\ 'make' : '%smake%smake%sm',
\ 'matlab' : '%smatlab%smatlab%sf',
\ 'ocaml' : '%socaml%socaml%scmMvtfCre',
\ 'pascal' : '%spascal%spascal%sfp',
\ 'perl' : '%sperl%sperl%sclps',
@ -69,16 +73,20 @@ let s:types = {
\ 'python' : '%spython%spython%scmf',
\ 'rexx' : '%srexx%srexx%ss',
\ 'ruby' : '%sruby%sruby%scfFm',
\ 'rust' : '%srust%srust%sfTgsmctid',
\ 'scheme' : '%sscheme%sscheme%ssf',
\ 'sh' : '%ssh%ssh%sf',
\ 'csh' : '%ssh%ssh%sf',
\ 'zsh' : '%ssh%ssh%sf',
\ 'scala' : '%sscala%sscala%sctTmlp',
\ 'slang' : '%sslang%sslang%snf',
\ 'sml' : '%ssml%ssml%secsrtvf',
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
\ 'tex' : '%stex%stex%sipcsubPGl',
\ 'tcl' : '%stcl%stcl%scfmp',
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
\ 'vhdl' : '%svhdl%svhdl%sPctTrefp',
\ 'vim' : '%svim%svim%savf',
\ 'yacc' : '%syacc%syacc%sl',
\ }
@ -130,7 +138,7 @@ fu! s:exectags(cmd)
endf
fu! s:exectagsonfile(fname, ftype)
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs --extra= ', a:ftype]
if type(s:types[ft]) == 1
let ags .= s:types[ft]
let bin = s:bin
@ -151,7 +159,11 @@ fu! s:esctagscmd(bin, args, ...)
let [ssl, &ssl] = [&ssl, 0]
en
let fname = a:0 ? shellescape(a:1) : ''
let cmd = shellescape(a:bin).' '.a:args.' '.fname
if (has('win32') || has('win64'))
let cmd = a:bin.' '.a:args.' '.fname
else
let cmd = shellescape(a:bin).' '.a:args.' '.fname
endif
if &sh =~ 'cmd\.exe'
let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
en

View file

@ -6,6 +6,7 @@
" Static variables {{{1
let [s:mrbs, s:mrufs] = [[], []]
let s:mruf_map_string = '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val'
fu! ctrlp#mrufiles#opts()
let [pref, opts] = ['g:ctrlp_mruf_', {
@ -15,6 +16,7 @@ fu! ctrlp#mrufiles#opts()
\ 'case_sensitive': ['s:cseno', 1],
\ 'relative': ['s:re', 0],
\ 'save_on_update': ['s:soup', 1],
\ 'map_string': ['g:ctrlp_mruf_map_string', s:mruf_map_string],
\ }]
for [ke, va] in items(opts)
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
@ -51,7 +53,7 @@ fu! s:reformat(mrufs, ...)
let cwd = tr(cwd, '\', '/')
cal map(a:mrufs, 'tr(v:val, "\\", "/")')
en
retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
retu map(a:mrufs, g:ctrlp_mruf_map_string)
endf
fu! s:record(bufnr)
@ -66,10 +68,12 @@ fu! s:record(bufnr)
endf
fu! s:addtomrufs(fname)
let fn = fnamemodify(a:fname, ':p')
let fn = fnamemodify(a:fname, get(g:, 'ctrlp_tilde_homedir', 0) ? ':p:~' : ':p')
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
let abs_fn = fnamemodify(fn,':p')
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
\ || !empty(getbufvar('^' . abs_fn . '$', '&bt')) || !filereadable(abs_fn)
retu
en
let idx = index(s:mrufs, fn, 0, !{s:cseno})
if idx
@ -143,7 +147,7 @@ fu! ctrlp#mrufiles#init()
let s:locked = 0
aug CtrlPMRUF
au!
au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au BufWinEnter,BufWinLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0
au VimLeavePre * cal s:savetofile(s:mergelists())

View file

@ -21,7 +21,7 @@ cal add(g:ctrlp_ext_vars, {
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:findcount(str)
fu! s:findcount(str, tgaddr)
let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$')
let tgs = taglist('^'.tg.'$')
if len(tgs) < 2
@ -48,7 +48,13 @@ fu! s:findcount(str)
for tgi in ntgs
let cnt += 1
if tgi["filename"] == ofname
let [fnd, pos] = [0, cnt]
if a:tgaddr != ""
if a:tgaddr == tgi["cmd"]
let [fnd, pos] = [0, cnt]
en
else
let [fnd, pos] = [0, cnt]
en
en
endfo
retu [1, fnd, pos, len(ctgs)]
@ -92,8 +98,9 @@ endf
fu! ctrlp#tag#accept(mode, str)
cal ctrlp#exit()
let tgaddr = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\t\zs[^\t]\{-1,}\ze\%(;"\)\?\t')
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
let [tg, fdcnt] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str, tgaddr)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
@ -121,6 +128,7 @@ fu! ctrlp#tag#accept(mode, str)
en
cal feedkeys(":".cmd." ".tg."\r".ext, 'nt')
en
cal feedkeys('zvzz', 'nt')
cal ctrlp#setlcdir()
endf

File diff suppressed because it is too large Load diff

View file

@ -63,18 +63,26 @@ Overview:~
|ctrlp_default_input|.........Seed the prompt with an initial string.
|ctrlp_abbrev|................Input abbreviations.
|ctrlp_key_loop|..............Use input looping for multi-byte input.
|ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames.
|ctrlp_prompt_mappings|.......Change the mappings inside the prompt.
|ctrlp_line_prefix|...........Prefix for each line in ctrlp window.
|ctrlp_open_single_match|.....Automatically accept when only one candidate.
|ctrlp_brief_prompt|..........Exit CtrlP on empty prompt by <bs>.
|ctrlp_match_current_file|....Include current file in match entries.
MRU mode:
|ctrlp_mruf_max|..............Max MRU entries to remember.
|ctrlp_mruf_exclude|..........Files that shouldn't be remembered.
|ctrlp_mruf_include|..........Files to be remembered.
|ctrlp_mruf_relative|.........Show only MRU files in the working directory.
|ctrlp_tilde_homedir|....Save MRU file paths in home dir as ~/.
|ctrlp_mruf_default_order|....Disable sorting.
|ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
|ctrlp_mruf_save_on_update|...Save to disk whenever a new entry is added.
Buffer mode:
|ctrlp_bufname_mod|...........File name section modificator.
|ctrlp_bufpath_mod|...........File path section modificator.
BufferTag mode: (to enable, see |ctrlp-extensions|)
|g:ctrlp_buftag_ctags_bin|....The location of the ctags-compatible binary.
|g:ctrlp_buftag_systemenc|....The encoding used for the ctags command.
@ -118,7 +126,7 @@ Set this to 1 to set regexp search as the default: >
Can be toggled on/off by pressing <c-r> inside the prompt.
*'g:ctrlp_match_window'*
Change the postion, the listing order of results, the minimum and the maximum
Change the position, the listing order of results, the minimum and the maximum
heights of the match window: >
let g:ctrlp_match_window = ''
<
@ -181,13 +189,12 @@ variable: >
let g:ctrlp_working_path_mode = 'ra'
<
c - the directory of the current file.
a - like "c", but only applies when the current working directory outside of
CtrlP isn't a direct ancestor of the directory of the current file.
r - the nearest ancestor that contains one of these directories or files:
a - the directory of the current file, unless it is a subdirectory of the cwd
r - the nearest ancestor of the current file that contains one of these
directories or files:
.git .hg .svn .bzr _darcs
w - begin finding a root from the current working directory outside of CtrlP
instead of from the directory of the current file (default). Only applies
when "r" is also present.
w - modifier to "r": start search from the cwd instead of the current file's
directory
0 or <empty> - disable this feature.
Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
@ -261,6 +268,9 @@ Examples: >
let g:ctrlp_custom_ignore = {
\ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@<!$'
\ }
let g:ctrlp_custom_ignore = {
\ 'func': 'some#custom#match_function'
\ }
<
Note #1: by default, |wildignore| and |g:ctrlp_custom_ignore| only apply when
|globpath()| is used to scan for files, thus these options do not apply when a
@ -269,6 +279,12 @@ command defined with |g:ctrlp_user_command| is being used.
Note #2: when changing the option's variable type, remember to |:unlet| it
first or restart Vim to avoid the "E706: Variable type mismatch" error.
Note #3: when using the "func" ignore type, you must provide the full name of
a function that can be called from CtrlP. An |autoload| function name is
recommended here. The function must take 2 parameters, the item to match and
its type. The type will be "dir", "file", or "link". The function must return
1 if the item should be ignored, 0 otherwise.
*'g:ctrlp_max_files'*
The maximum number of files to scan, set to 0 for no limit: >
let g:ctrlp_max_files = 10000
@ -327,7 +343,7 @@ Some examples: >
" Single VCS, listing command lists untracked files (slower):
let g:ctrlp_user_command =
\ ['.git', 'cd %s && git ls-files . -co --exclude-standard']
\ ['.git', 'cd %s && git ls-files -co --exclude-standard']
let g:ctrlp_user_command =
\ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux
@ -434,6 +450,17 @@ Instead of 1 or 0, if the value of the option is a string, it'll be used as-is
as the default input: >
let g:ctrlp_default_input = 'anystring'
<
This option works well together with |g:ctrlp_open_single_match|
*'g:ctrlp_match_current_file'*
Includes the current file in the match entries:
let g:ctrlp_match_current_file = 1
By default, the current file is excluded from the list.
Note: does not apply when |g:ctrlp_match_func| is used.
*'g:ctrlp_abbrev'*
Define input abbreviations that can be expanded (either internally or visibly)
@ -497,12 +524,6 @@ Note #2: you can toggle this feature inside the prompt with a custom mapping: >
let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': ['<F3>'] }
<
*'g:ctrlp_use_migemo'*
Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
works in regexp mode. To split the pattern, separate words with space: >
let g:ctrlp_use_migemo = 0
<
*'g:ctrlp_prompt_mappings'*
Use this to customize the mappings inside CtrlP's prompt to your liking. You
only need to keep the lines that you've changed the values (inside []): >
@ -549,6 +570,34 @@ default <c-h> mapping: >
let g:ctrlp_prompt_mappings = { 'PrtCurLeft()': ['<left>', '<c-^>'] }
<
*'g:ctrlp_line_prefix'*
This prefix will be prepended to each line in ctrlp's item listing.
default: >
let g:ctrlp_line_prefix = '> '
<
*'g:ctrlp_open_single_match'*
List of CtrlP modes for which CtrlP should accept an entry directly, if only
one candidate exists.
Example: >
let g:ctrlp_open_single_match = ['buffer tags', 'buffer']
<
This is currently only really useful together with |g:ctrlp_default_input|
set before launching, and cleared afterwards, with a function such as
following: >
fu! <SID>tagsUnderCursor()
try
let default_input_save = get(g:, 'ctrlp_default_input', '')
let g:ctrlp_default_input = expand('<cword>')
CtrlPBufTagAll
finally
if exists('default_input_save')
let g:ctrlp_default_input = default_input_save
endif
endtry
endfu
>
<
----------------------------------------
MRU mode options:~
@ -574,6 +623,14 @@ Example: >
let g:ctrlp_mruf_include = '\.py$\|\.rb$'
<
*'g:ctrlp_tilde_homedir'*
Set this to 1 to save every MRU file path $HOME/$filepath in the $HOME dir
as ~/$filepath instead of $HOME/$filepath : >
let g:ctrlp_tilde_homedir = 0
<
Note: This applies also to all dir paths stored by :CtrlPBookmarkDirAdd!
<
*'g:ctrlp_mruf_relative'*
Set this to 1 to show only MRU files in the current working directory: >
let g:ctrlp_mruf_relative = 0
@ -581,7 +638,6 @@ Set this to 1 to show only MRU files in the current working directory: >
Note: you can use a custom mapping to toggle this option inside the prompt: >
let g:ctrlp_prompt_mappings = { 'ToggleMRURelative()': ['<F2>'] }
<
*'g:ctrlp_mruf_default_order'*
Set this to 1 to disable sorting when searching in MRU mode: >
let g:ctrlp_mruf_default_order = 0
@ -598,7 +654,14 @@ Set this to 0 to disable saving of the MRU list to hard drive whenever a new
entry is added, saving will then only occur when exiting Vim: >
let g:ctrlp_mruf_save_on_update = 1
<
*'g:ctrlp_bufname_mod'*
Modify file name section according to modificator string. See |filename-modifiers|. >
let g:ctrlp_bufname_mod = ':t'
<
*'g:ctrlp_bufpath_mod'*
Modify file path section according to modificator string. See |filename-modifiers|. >
let g:ctrlp_bufpath_mod = ':~:.:h'
<
----------------------------------------
Advanced options:~
@ -772,6 +835,15 @@ Example: >
" }
endfunction
<
*'g:ctrlp_brief_prompt'*
When this is set to 1, the <bs> on empty prompt exit CtrlP.
*ctrlp-default-value*
Otherwize, you can use below to change default value.
Example: >
let g:ctrlp_path_nolim = 1
This is possible to change no-limit mode for match type "path".
===============================================================================
COMMANDS *ctrlp-commands*
@ -953,8 +1025,12 @@ Function keys:~
- Remove deleted files from the MRU list.
<F7>
- Wipe the MRU list.
- Delete MRU entries marked by <c-z>.
MRU mode:
- Wipe the list.
- Delete entries marked by <c-z>.
Buffer mode:
- Delete entry under the cursor or delete multiple entries marked by <c-z>.
Pasting:~
@ -1027,7 +1103,7 @@ d) Submit two dots '..' to go upward the directory tree by 1 level. To go up
e) Similarly, submit '/' or '\' to find and go to the project's root.
If the project is large, using a VCS listing command to look for files
might help speeding up the intial scan (see |g:ctrlp_user_command| for more
might help speeding up the initial scan (see |g:ctrlp_user_command| for more
details).
Note: d) and e) only work in file, directory and mixed modes.
@ -1138,8 +1214,27 @@ Available extensions:~
* BookmarkDir mode:~
- Name: 'bookmarkdir'
- Commands: ":CtrlPBookmarkDir",
":CtrlPBookmarkDirAdd [directory]".
":CtrlPBookmarkDirAdd [directory] [TITLE]".
":CtrlPBookmarkDirAdd! [directory] [TITLE]".
- Search for a bookmarked directory and change the working directory to it.
- Add either the dir [directory], if supplied, or otherwise ask for it,
under the title given by either [TITLE], if supplied, or otherwise ask for
it, to the CtrlPBookmarkDir list.
- Add either the dir [directory], if supplied, or otherwise the current
work dir ( [CWD] ) under the title given by either [TITLE], if supplied,
or otherwise [CWD] to the CtrlPBookmarkDir list.
The last command can be used to add all recently used work dirs to the
CtrlPBookmarkDir list by an autocommand like
>
augroup CtrlPDirMRU
autocmd!
autocmd FileType * if &modifiable | execute 'silent CtrlPBookmarkDirAdd! %:p:h' | endif
augroup END
<
- Mappings:
+ <cr> change the local working directory for CtrlP, keep it open and
switch to find file mode.
@ -1149,6 +1244,80 @@ Available extensions:~
- Wipe bookmark list.
- Delete entries marked by <c-z>.
*ctrlp-autoignore-extension*
* Autoignore mode:~
- Name: 'autoignore'
- This extension doesn't add new commands. It adds support for per-project
ignore patterns (as per |ctrlp_custom_ignore|) via a `.ctrlpignore` file
at the root of the project. It's basically like a `.gitignore` or
`.hgignore` for CtrlP.
Note: auto-ignore won't work when |g:ctrlp_user_command| is used.
Note: `.ctrlpignore` will be added to the root markers (see
|g:ctrlp_root_markers|).
- Ignore file syntax:
Empty lines, and lines starting with `#` (comments) are ignored.
Other lines are treated like regular expression patterns. See *string-match*
for how patterns are used. Anything that matches any of the patterns will be
ignored from CtrlP's search results.
Example:
\.tmp$
^generated/
local\.cfg
Note: patterns should use forward slashes, even on Windows.
You can also switch to a glob-like syntax like this:
syntax:wildignore
*.tar.gz
*.tmp
This will temporarily add each pattern to |'wildignore'| for the
duration of the file scan, and remove them at the end.
You can switch back to the default regular-expression-based patterns by
writing:
syntax:regexp
You can also specify a match on only a given type of item:
dir:build
file:foo\.txt
This will only ignore directories with "build" in them, and files with
"foo.txt" in them. Not files with "build" in them or vice-versa.
Note: to ignore a root directory "build", and not _any_ directory with
"build" in it, you can root the regex: ^build$
- FAQ:
Q: Why can't CtrlP support `.gitignore` or `.hgignore` natively?
A: Those files look at first like they may contain all the patterns
you'd want to exclude from CtrlP already. However, more often than not,
there are some differences. Those files list patterns that should not be
included in source-control. This includes things you want to ignore, but
also things you may not want to: local settings, external packages and
dependencies, etc. The author felt the trouble of supporting various
syntaxes was too much compared to just copy/pasting a few lines. Feel
free to contribute a patch if you disagree :)
Q: I enabled |ctrlp-autoignore-extension|, or edited `.ctrlpignore`, but
none of the new patterns are working. What did I do wrong?
A: Probably nothing! CtrlP can cache search results for faster response
times. You can hit <F5> to force it to refresh. This will use the newer
ignore patterns if the `.ctrlpignore` file has changed, too.
----------------------------------------
Buffer Tag mode options:~
@ -1189,6 +1358,17 @@ Highlighting:~
CtrlPPrtText : the prompt's text (|hl-Normal|)
CtrlPPrtCursor : the prompt's cursor when moving over the text (Constant)
* Buffer explorer mode:
CtrlPBufferNr : buffer number
CtrlPBufferInd : '+', '-', '=' and '#' indicators (see |:buffers|)
CtrlPBufferHid : hidden buffer
CtrlPBufferHidMod : hidden and modified buffer
CtrlPBufferVis : visible buffer
CtrlPBufferVisMod : visible and modified buffer
CtrlPBufferCur : current buffer
CtrlPBufferCurMod : current and modified buffer
CtrlPBufferPath : buffer path
* In extensions:
CtrlPTabExtra : the part of each line that's not matched against (Comment)
CtrlPBufName : the buffer name an entry belongs to (|hl-Directory|)
@ -1259,11 +1439,12 @@ MISCELLANEOUS CONFIGS *ctrlp-miscellaneous-configs*
===============================================================================
CREDITS *ctrlp-credits*
Developed by Kien Nguyen <github.com/kien>. Distributed under Vim's |license|.
Originally developed by Kien Nguyen <github.com/kien>. Now maintained by the
members of the ctrlpvim Github organisation
(https://github.com/orgs/ctrlpvim/people). Distributed under Vim's |license|.
Project's homepage: http://kien.github.com/ctrlp.vim
Git repository: https://github.com/kien/ctrlp.vim
Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
Project's homepage: http://ctrlpvim.github.com/ctrlp.vim
Git repository: https://github.com/ctrlpvim/ctrlp.vim
-------------------------------------------------------------------------------
Thanks to everyone that has submitted ideas, bug reports or helped debugging on
@ -1290,10 +1471,14 @@ Special thanks:~
* Jo De Boeck <github.com/grimpy>
* Rudi Grinberg <github.com/rgrinberg>
* Timothy Mellor <github.com/mellort>
* Sergey Vlasov <github.com/noscript>
===============================================================================
CHANGELOG *ctrlp-changelog*
+ New buffer explorer mode with highlighting (|+conceal| recommended)
+ New options: |g:ctrlp_bufname_mod|,
|g:ctrlp_bufpath_mod|
+ Combine *g:ctrlp_match_window_bottom* *g:ctrlp_match_window_reversed* and
*g:ctrlp_max_height* into |g:ctrlp_match_window|.
+ New option: |g:ctrlp_match_window|.

View file

@ -33,8 +33,10 @@ com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })
if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
exe 'nn <silent> <plug>(ctrlp) :<c-u>'.g:ctrlp_cmd.'<cr>'
if g:ctrlp_map != '' && !hasmapto('<plug>(ctrlp)')
exe 'map' g:ctrlp_map '<plug>(ctrlp)'
en
cal ctrlp#mrufiles#init()
@ -62,7 +64,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=dir CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)
com! -n=? -com=dir -bang CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', '<bang>', <q-args>)
" vim:ts=2:sw=2:sts=2

View file

@ -1,6 +1,3 @@
#**This project is unmaintained**
**You should use [this fork](https://github.com/ctrlpvim/ctrlp.vim) instead.**
# ctrlp.vim
Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim.
@ -47,20 +44,27 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi
let g:ctrlp_cmd = 'CtrlP'
```
* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:
* When invoked without an explicit starting directory, CtrlP will set its local working directory according to this variable:
```vim
let g:ctrlp_working_path_mode = 'ra'
```
`'c'` - the directory of the current file.
`'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
`'a'` - the directory of the current file, unless it is a subdirectory of the cwd
`'r'` - the nearest ancestor of the current file that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'w'` - modifier to "r": start search from the cwd instead of the current file's directory
`0` or `''` (empty string) - disable this feature.
Define additional root markers with the `g:ctrlp_root_markers` option.
If none of the default markers (`.git` `.hg` `.svn` `.bzr` `_darcs`) are present in a project, you can define additional ones with `g:ctrlp_root_markers`:
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`:
```vim
let g:ctrlp_root_markers = ['pom.xml', '.p4ignore']
```
If more than one mode is specified, they will be tried in order until a directory is located.
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`. If a custom listing command is being used, exclusions are ignored:
```vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
@ -81,11 +85,17 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
```
* Ignore files in `.gitignore`
```vim
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
```
Check `:help ctrlp-options` for other options.
## Installation
Use your favorite method or check the homepage for a [quick installation guide][3].
[1]: http://i.imgur.com/yIynr.png
[2]: https://github.com/kien/ctrlp.vim/tree/extensions
[3]: http://kien.github.com/ctrlp.vim#installation
[1]: http://i.imgur.com/aOcwHwt.png
[2]: https://github.com/ctrlpvim/ctrlp.vim/tree/extensions
[3]: http://ctrlpvim.github.com/ctrlp.vim#installation

View file

@ -19,7 +19,7 @@ PLUGINS = """
ack.vim https://github.com/mileszs/ack.vim
ag.vim https://github.com/rking/ag.vim
bufexplorer https://github.com/corntrace/bufexplorer
ctrlp.vim https://github.com/kien/ctrlp.vim
ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim
mayansmoke https://github.com/vim-scripts/mayansmoke
nerdtree https://github.com/scrooloose/nerdtree
nginx-vim-syntax https://github.com/evanmiller/nginx-vim-syntax