Resolve some issues
* Remove active buffer from MRU listing. Close #66. * Re-evaluate ctrlp_user_command when changing dir. Fix #69. * Link to custom ctrlp_user_command config in the docs. Close #70.
This commit is contained in:
parent
34a2cae6c6
commit
f04196941a
@ -190,13 +190,13 @@ fu! s:lsCmd()
|
|||||||
if type(cmd) == 1
|
if type(cmd) == 1
|
||||||
retu cmd
|
retu cmd
|
||||||
elsei type(cmd) == 3 && len(cmd) >= 2 && !empty(cmd[0]) && !empty(cmd[1])
|
elsei type(cmd) == 3 && len(cmd) >= 2 && !empty(cmd[0]) && !empty(cmd[1])
|
||||||
let rmarker = cmd[0]
|
|
||||||
" Find a repo root
|
" Find a repo root
|
||||||
cal s:findroot(getcwd(), rmarker, 0, 1)
|
cal s:findroot(getcwd(), cmd[0], 0, 1)
|
||||||
if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) )
|
if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) )
|
||||||
" Try the secondary_command
|
" Try the secondary_command
|
||||||
retu len(cmd) == 3 ? cmd[2] : ''
|
retu len(cmd) == 3 ? cmd[2] : ''
|
||||||
en
|
en
|
||||||
|
unl! s:vcsroot
|
||||||
let s:vcscmd = s:lash == '\' ? 1 : 0
|
let s:vcscmd = s:lash == '\' ? 1 : 0
|
||||||
retu cmd[1]
|
retu cmd[1]
|
||||||
en
|
en
|
||||||
@ -742,19 +742,17 @@ fu! s:AcceptSelection(mode)
|
|||||||
if a:mode == 'e' | if s:SpecInputs() | retu | en | en
|
if a:mode == 'e' | if s:SpecInputs() | retu | en | en
|
||||||
" Get the selected line
|
" Get the selected line
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
if line == ' == NO ENTRIES =='
|
if a:mode != 'e' && s:itemtype < 3 && line == ' == NO ENTRIES =='
|
||||||
cal <SID>CreateNewFile()
|
cal s:CreateNewFile(a:mode) | retu
|
||||||
retu
|
|
||||||
en
|
en
|
||||||
let matchstr = matchstr(line, '^> \zs.\+\ze\t*$')
|
let matchstr = matchstr(line, '^> \zs.\+\ze\t*$')
|
||||||
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
|
|
||||||
if empty(matchstr) | retu | en
|
if empty(matchstr) | retu | en
|
||||||
" Do something with it
|
" Do something with it
|
||||||
let actfunc = s:itemtype =~ '0\|1\|2' ? 'ctrlp#acceptfile'
|
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile'
|
||||||
\ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][1]
|
\ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][1]
|
||||||
cal call(actfunc, [a:mode, matchstr])
|
cal call(actfunc, [a:mode, matchstr])
|
||||||
endf
|
endf
|
||||||
fu! s:CreateNewFile() "{{{1
|
fu! s:CreateNewFile(...) "{{{1
|
||||||
let str = join(s:prompt, '')
|
let str = join(s:prompt, '')
|
||||||
if empty(str) | retu | en
|
if empty(str) | retu | en
|
||||||
let str = s:sanstail(str)
|
let str = s:sanstail(str)
|
||||||
@ -769,9 +767,9 @@ fu! s:CreateNewFile() "{{{1
|
|||||||
let filpath = getcwd().s:lash.optyp
|
let filpath = getcwd().s:lash.optyp
|
||||||
cal s:insertcache(str)
|
cal s:insertcache(str)
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
let cmd = s:newfop == 1 ? 'tabe'
|
let cmd = s:newfop == 1 || ( a:0 && a:1 == 't' ) ? 'tabe'
|
||||||
\ : s:newfop == 2 ? 'new'
|
\ : s:newfop == 2 || ( a:0 && a:1 == 'h' ) ? 'new'
|
||||||
\ : s:newfop == 3 ? 'vne' : ctrlp#normcmd('e')
|
\ : s:newfop == 3 || ( a:0 && a:1 == 'v' ) ? 'vne' : ctrlp#normcmd('e')
|
||||||
cal s:openfile(cmd, filpath)
|
cal s:openfile(cmd, filpath)
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
@ -1089,6 +1087,7 @@ fu! ctrlp#recordhist()
|
|||||||
if len(hst) > 1 && hst[1] == str | retu | en
|
if len(hst) > 1 && hst[1] == str | retu | en
|
||||||
cal extend(hst, [str], 1)
|
cal extend(hst, [str], 1)
|
||||||
if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en
|
if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en
|
||||||
|
cal ctrlp#utils#writecache(hst, s:gethistloc()[0], s:gethistloc()[1])
|
||||||
endf
|
endf
|
||||||
" Signs {{{2
|
" Signs {{{2
|
||||||
fu! s:unmarksigns()
|
fu! s:unmarksigns()
|
||||||
@ -1181,7 +1180,6 @@ fu! s:leavepre()
|
|||||||
\ ( has('clientserver') && len(split(serverlist(), "\n")) == 1 ) )
|
\ ( has('clientserver') && len(split(serverlist(), "\n")) == 1 ) )
|
||||||
cal ctrlp#clra(1)
|
cal ctrlp#clra(1)
|
||||||
en
|
en
|
||||||
cal ctrlp#utils#writecache(s:hstry, s:gethistloc()[0], s:gethistloc()[1])
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:checkbuf()
|
fu! s:checkbuf()
|
||||||
|
@ -15,42 +15,46 @@ fu! ctrlp#mrufiles#opts()
|
|||||||
for [ke, va] in items(opts)
|
for [ke, va] in items(opts)
|
||||||
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
|
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
|
||||||
endfo
|
endfo
|
||||||
|
let s:csen = s:csen ? '#' : '?'
|
||||||
|
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
|
||||||
|
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
|
||||||
endf
|
endf
|
||||||
cal ctrlp#mrufiles#opts()
|
cal ctrlp#mrufiles#opts()
|
||||||
fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
|
fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
|
||||||
if s:locked | retu | en
|
if s:locked | retu | en
|
||||||
" Get the list
|
" Get the list
|
||||||
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
|
let mrufs = ctrlp#utils#readfile(s:cafile)
|
||||||
let cafile = cadir.ctrlp#utils#lash().'cache.txt'
|
|
||||||
let mrufs = ctrlp#utils#readfile(cafile)
|
|
||||||
" Remove non-existent files
|
" Remove non-existent files
|
||||||
if exists('a:1') && a:1 == 1
|
if a:0 && a:1 == 1
|
||||||
let mrufs = s:rmdeleted(mrufs, cadir, cafile)
|
let mrufs = s:rmdeleted(mrufs)
|
||||||
elsei exists('a:1') && a:1 == 2
|
elsei a:0 && a:1 == 2
|
||||||
cal ctrlp#utils#writecache([], cadir, cafile)
|
cal ctrlp#utils#writecache([], s:cadir, s:cafile)
|
||||||
retu []
|
retu []
|
||||||
en
|
en
|
||||||
" Return the list
|
" Return the list, filter the active buffer
|
||||||
if a:bufnr == -1 | retu mrufs | en
|
if a:bufnr == -1
|
||||||
|
let crfile = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
|
||||||
|
retu empty(crfile) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crfile')
|
||||||
|
en
|
||||||
" Filter it
|
" Filter it
|
||||||
let filename = fnamemodify(bufname(a:bufnr + 0), ':p')
|
let filename = fnamemodify(bufname(a:bufnr + 0), ':p')
|
||||||
if empty(filename) || !empty(&bt)
|
if empty(filename) || !empty(&bt)
|
||||||
\ || ( !empty(s:include) && filename !~# s:include )
|
\ || ( !empty(s:include) && filename !~# s:include )
|
||||||
\ || ( !empty(s:exclude) && filename =~# s:exclude )
|
\ || ( !empty(s:exclude) && filename =~# s:exclude )
|
||||||
\ || ( index(mrufs, filename) == -1 && !filereadable(filename) )
|
\ || ( index(mrufs, filename) < 0 && !filereadable(filename) )
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
" Remove old matched entry
|
" Remove old matched entry
|
||||||
cal filter(mrufs, 'v:val !='.( s:csen ? "#" : "?" ).' filename')
|
cal filter(mrufs, 'v:val !='.s:csen.' filename')
|
||||||
" Insert new one
|
" Insert new one
|
||||||
cal insert(mrufs, filename)
|
cal insert(mrufs, filename)
|
||||||
" Remove oldest entry
|
" Remove oldest entry
|
||||||
if len(mrufs) > s:max | cal remove(mrufs, s:max, -1) | en
|
if len(mrufs) > s:max | cal remove(mrufs, s:max, -1) | en
|
||||||
cal ctrlp#utils#writecache(mrufs, cadir, cafile)
|
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||||
endf "}}}
|
endf "}}}
|
||||||
fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
|
fu! s:rmdeleted(mrufs) "{{{
|
||||||
cal filter(a:mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
|
cal filter(a:mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
|
||||||
cal ctrlp#utils#writecache(a:mrufs, a:cadir, a:cafile)
|
cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
|
||||||
retu a:mrufs
|
retu a:mrufs
|
||||||
endf
|
endf
|
||||||
fu! ctrlp#mrufiles#init() "{{{1
|
fu! ctrlp#mrufiles#init() "{{{1
|
||||||
|
@ -115,7 +115,8 @@ be enabled for directories that have more than 4000 files: >
|
|||||||
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
|
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
|
||||||
|
|
||||||
*'g:ctrlp_clear_cache_on_exit'*
|
*'g:ctrlp_clear_cache_on_exit'*
|
||||||
Set this to 0 to enable cross-sessions caching: >
|
Set this to 0 to enable cross-sessions caching by not clearing the cache files
|
||||||
|
upon exiting Vim: >
|
||||||
let g:ctrlp_clear_cache_on_exit = 1
|
let g:ctrlp_clear_cache_on_exit = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
@ -287,7 +288,7 @@ The maximum number of input strings you want |CtrlP| to remember. The default
|
|||||||
value mirrors Vim’s global |'history'| option: >
|
value mirrors Vim’s global |'history'| option: >
|
||||||
let g:ctrlp_max_history = &history
|
let g:ctrlp_max_history = &history
|
||||||
<
|
<
|
||||||
Set to 0 to disable prompt’s history.
|
Set to 0 to disable prompt’s history. Browse the history with <c-n> and <c-p>.
|
||||||
|
|
||||||
*'g:ctrlp_open_multi'*
|
*'g:ctrlp_open_multi'*
|
||||||
If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
|
If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
|
||||||
@ -515,8 +516,8 @@ c) End the string with a colon ':' followed by a Vim command to execute that
|
|||||||
instance of 'my:function'.
|
instance of 'my:function'.
|
||||||
'abc:+setf\ myfiletype|50' will open the selected file and set its
|
'abc:+setf\ myfiletype|50' will open the selected file and set its
|
||||||
filetype to 'myfiletype', then jump to line 50.
|
filetype to 'myfiletype', then jump to line 50.
|
||||||
'abc:difft' will open the selected file and run |:diffthis| on the first
|
'abc:diffthis' will open the selected file and run |:diffthis| on the
|
||||||
four files.
|
first 4 files.
|
||||||
|
|
||||||
See also Vim’s |++opt| and |+cmd|.
|
See also Vim’s |++opt| and |+cmd|.
|
||||||
|
|
||||||
@ -657,6 +658,30 @@ Special thanks:~
|
|||||||
* Yasuhiro Matsumoto <github.com/mattn>
|
* Yasuhiro Matsumoto <github.com/mattn>
|
||||||
Added option to use Migemo for Japanese language.
|
Added option to use Migemo for Japanese language.
|
||||||
|
|
||||||
|
* Kyo Nagashima <github.com/hail2u>
|
||||||
|
Made some enhancements to file opening mappings.
|
||||||
|
|
||||||
|
* Simon Ruderich
|
||||||
|
* Ken Earley <github.com/kenearley>
|
||||||
|
* Zak Johnson <github.com/zakj>
|
||||||
|
* Diego Viola <github.com/diegoviola>
|
||||||
|
Bugfixes/Corrections.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
USERS-CONFIGURATION *ctrlp-users-config*
|
||||||
|
|
||||||
|
Some configurations for your .vimrc:~
|
||||||
|
|
||||||
|
+) MRU ==> MRE (most-recently-entered): >
|
||||||
|
autocmd BufEnter * call ctrlp#mrufiles#list(expand('<abuf>', 1))
|
||||||
|
<
|
||||||
|
The default implementation of MRU is similar to that of desktop applications.
|
||||||
|
Use the above |autocmd| to change it to recording most-recently-entered buffers
|
||||||
|
(that have a file) instead.
|
||||||
|
|
||||||
|
+) |g:ctrlp_user_command| config that makes use of your |wildignore| setting:
|
||||||
|
https://github.com/kien/ctrlp.vim/issues/70 by Rich Alesi
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
CHANGELOG *ctrlp-changelog*
|
CHANGELOG *ctrlp-changelog*
|
||||||
|
|
||||||
|
@ -75,6 +75,6 @@ Examples:
|
|||||||
|
|
||||||
_Check [the docs][2] for more mappings, commands and options._
|
_Check [the docs][2] for more mappings, commands and options._
|
||||||
|
|
||||||
[1]: http://i.imgur.com/3rtLt.png
|
[1]: http://i.imgur.com/yIynr.png
|
||||||
[2]: https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt
|
[2]: https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt
|
||||||
[3]: https://github.com/kien/ctrlp.vim/tree/extensions
|
[3]: https://github.com/kien/ctrlp.vim/tree/extensions
|
||||||
|
Loading…
Reference in New Issue
Block a user