1
0
Fork 0
mirror of synced 2025-02-14 13:04:59 -05:00

Merge pull request #190 from HouCoder/use-ctrlpvim/ctrlp.vim

Use ctrlpvim/ctrlp.vim instead of unmaintained kien/ctrlp.vim
This commit is contained in:
Amir Salihefendic 2016-05-14 17:08:14 +01:00
commit 7445f07fd3
13 changed files with 2400 additions and 169 deletions

View file

@ -67,7 +67,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