Don't save and restore &tags option
Fix #86 Also: * Make <F5> in MRU mode also remove excluded files. * Make switching MRU and MRE an option. Close #87. * Improve handling of some option vars.
This commit is contained in:
parent
b3b8f7beae
commit
4110144ae4
@ -45,6 +45,7 @@ fu! s:opts()
|
|||||||
endfo
|
endfo
|
||||||
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
||||||
let s:maxdepth = min([s:maxdepth, 100])
|
let s:maxdepth = min([s:maxdepth, 100])
|
||||||
|
let s:mxheight = max([s:mxheight, 1])
|
||||||
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
|
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
|
||||||
" Extensions
|
" Extensions
|
||||||
let g:ctrlp_builtins = 2
|
let g:ctrlp_builtins = 2
|
||||||
@ -1087,11 +1088,10 @@ fu! s:findroot(curr, mark, depth, type)
|
|||||||
let [depth, notfound] = [a:depth + 1, empty(s:glbpath(a:curr, a:mark, 1))]
|
let [depth, notfound] = [a:depth + 1, empty(s:glbpath(a:curr, a:mark, 1))]
|
||||||
if !notfound || depth > s:maxdepth
|
if !notfound || depth > s:maxdepth
|
||||||
if notfound | cal ctrlp#setdir(s:cwd) | en
|
if notfound | cal ctrlp#setdir(s:cwd) | en
|
||||||
if a:type | if depth <= s:maxdepth
|
if a:type && depth <= s:maxdepth
|
||||||
let s:vcsroot = a:curr
|
let s:vcsroot = a:curr
|
||||||
en | el
|
elsei !a:type && !notfound
|
||||||
cal ctrlp#setdir(a:curr)
|
cal ctrlp#setdir(a:curr) | let s:foundroot = 1
|
||||||
let s:foundroot = 1
|
|
||||||
en
|
en
|
||||||
el
|
el
|
||||||
let parent = s:getparent(a:curr)
|
let parent = s:getparent(a:curr)
|
||||||
|
@ -12,6 +12,7 @@ fu! ctrlp#mrufiles#opts()
|
|||||||
\ 'g:ctrlp_mruf_exclude': ['s:exclude', ''],
|
\ 'g:ctrlp_mruf_exclude': ['s:exclude', ''],
|
||||||
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
|
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
|
||||||
\ 'g:ctrlp_mruf_relative': ['s:relate', 0],
|
\ 'g:ctrlp_mruf_relative': ['s:relate', 0],
|
||||||
|
\ 'g:ctrlp_mruf_last_entered': ['s:mre', 0],
|
||||||
\ }
|
\ }
|
||||||
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])
|
||||||
@ -43,7 +44,7 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
|
|||||||
let mrufs = ctrlp#utils#readfile(s:cafile)
|
let mrufs = ctrlp#utils#readfile(s:cafile)
|
||||||
" Remove non-existent files
|
" Remove non-existent files
|
||||||
if a:0 && a:1 == 1
|
if a:0 && a:1 == 1
|
||||||
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
|
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
|
||||||
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||||
en
|
en
|
||||||
" Return the list with the active buffer removed
|
" Return the list with the active buffer removed
|
||||||
@ -65,12 +66,19 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
|
|||||||
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, s:cadir, s:cafile)
|
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||||
endf "}}}
|
endf "}}}
|
||||||
|
fu! s:excl(fname) "{{{
|
||||||
|
retu !empty(s:exclude) && a:fname =~# s:exclude
|
||||||
|
endf "}}}
|
||||||
fu! ctrlp#mrufiles#init() "{{{1
|
fu! ctrlp#mrufiles#init() "{{{1
|
||||||
let s:locked = 0
|
let s:locked = 0
|
||||||
aug CtrlPMRUF
|
aug CtrlPMRUF
|
||||||
au!
|
au!
|
||||||
au BufReadPost,BufNewFile,BufWritePost *
|
au BufReadPost,BufNewFile,BufWritePost *
|
||||||
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
|
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
|
||||||
|
if s:mre
|
||||||
|
au BufEnter,BufUnload *
|
||||||
|
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
|
||||||
|
en
|
||||||
au QuickFixCmdPre *vimgrep* let s:locked = 1
|
au QuickFixCmdPre *vimgrep* let s:locked = 1
|
||||||
au QuickFixCmdPost *vimgrep* let s:locked = 0
|
au QuickFixCmdPost *vimgrep* let s:locked = 0
|
||||||
aug END
|
aug END
|
||||||
|
@ -33,8 +33,7 @@ endf
|
|||||||
|
|
||||||
fu! s:findcount(str)
|
fu! s:findcount(str)
|
||||||
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
|
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
|
||||||
let [&l:tags, fname] = [s:ltags, expand(fname, 1)]
|
let [fname, tgs] = [expand(fname, 1), taglist('^'.tg.'$')]
|
||||||
let tgs = taglist('^'.tg.'$')
|
|
||||||
if empty(tgs) | retu [1, 1] | en
|
if empty(tgs) | retu [1, 1] | en
|
||||||
let [fnd, ct, pos] = [0, 0, 0]
|
let [fnd, ct, pos] = [0, 0, 0]
|
||||||
for each in tgs
|
for each in tgs
|
||||||
@ -68,9 +67,7 @@ endf
|
|||||||
" Public {{{1
|
" Public {{{1
|
||||||
fu! ctrlp#tag#init(tagfiles)
|
fu! ctrlp#tag#init(tagfiles)
|
||||||
if empty(a:tagfiles) | retu [] | en
|
if empty(a:tagfiles) | retu [] | en
|
||||||
let tagfiles = sort(s:nodup(a:tagfiles))
|
let [tagfiles, g:ctrlp_alltags] = [sort(s:nodup(a:tagfiles)), []]
|
||||||
let s:ltags = join(tagfiles, ',')
|
|
||||||
let g:ctrlp_alltags = []
|
|
||||||
for each in tagfiles
|
for each in tagfiles
|
||||||
let alltags = s:filter(ctrlp#utils#readfile(each))
|
let alltags = s:filter(ctrlp#utils#readfile(each))
|
||||||
cal extend(g:ctrlp_alltags, alltags)
|
cal extend(g:ctrlp_alltags, alltags)
|
||||||
@ -86,17 +83,18 @@ fu! ctrlp#tag#accept(mode, str)
|
|||||||
let [md, tg] = [a:mode, split(str, '^[^\t]\+\zs\t')[0]]
|
let [md, tg] = [a:mode, split(str, '^[^\t]\+\zs\t')[0]]
|
||||||
let fnd = s:findcount(str)
|
let fnd = s:findcount(str)
|
||||||
let cmds = {
|
let cmds = {
|
||||||
\ 't': ['tabe', 'tab stj'],
|
\ 't': ['tab sp', 'tab stj'],
|
||||||
\ 'h': ['new', 'stj'],
|
\ 'h': ['sp', 'stj'],
|
||||||
\ 'v': ['vne', 'vert stj'],
|
\ 'v': ['vs', 'vert stj'],
|
||||||
\ 'e': ['ene', 'tj'],
|
\ 'e': ['', 'tj'],
|
||||||
\ }
|
\ }
|
||||||
let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1]
|
let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1]
|
||||||
let cmd = cmd =~ 'tj\|ene' && &modified ? 'hid '.cmd : cmd
|
let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd
|
||||||
try
|
try
|
||||||
if fnd[0] == 1
|
if fnd[0] == 1
|
||||||
exe cmd
|
if cmd != ''
|
||||||
let &l:tags = s:ltags
|
exe cmd
|
||||||
|
en
|
||||||
exe fnd[1].'ta' tg
|
exe fnd[1].'ta' tg
|
||||||
el
|
el
|
||||||
exe cmd.' '.tg
|
exe cmd.' '.tg
|
||||||
|
@ -66,8 +66,8 @@ Set this to 0 to show the match window at the top of the screen: >
|
|||||||
<
|
<
|
||||||
|
|
||||||
*'g:ctrlp_match_window_reversed'*
|
*'g:ctrlp_match_window_reversed'*
|
||||||
Reverse the sort order of the matched files in the match window. The default
|
Change the listing order of the matched files in the match window. The default
|
||||||
setting is from bottom to top: >
|
setting (1) is from bottom to top: >
|
||||||
let g:ctrlp_match_window_reversed = 1
|
let g:ctrlp_match_window_reversed = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ Specify the number of recently opened files you want |CtrlP| to remember: >
|
|||||||
<
|
<
|
||||||
|
|
||||||
*'g:ctrlp_mruf_exclude'*
|
*'g:ctrlp_mruf_exclude'*
|
||||||
Files you don’t want |CtrlP| to remember; use |regexp| to specify the patterns:
|
Files you don’t want |CtrlP| to remember. Use |regexp| to specify the patterns:
|
||||||
>
|
>
|
||||||
let g:ctrlp_mruf_exclude = ''
|
let g:ctrlp_mruf_exclude = ''
|
||||||
<
|
<
|
||||||
@ -207,6 +207,11 @@ MRU entries: >
|
|||||||
let g:ctrlp_mruf_case_sensitive = 1
|
let g:ctrlp_mruf_case_sensitive = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
|
*'g:ctrlp_mruf_last_entered'*
|
||||||
|
Set to 1 to sort the MRU file list to most-recently-entered-buffer order: >
|
||||||
|
let g:ctrlp_mruf_last_entered = 0
|
||||||
|
<
|
||||||
|
|
||||||
*'g:ctrlp_dotfiles'*
|
*'g:ctrlp_dotfiles'*
|
||||||
Set this to 0 if you don’t want |CtrlP| to search for dotfiles and dotdirs: >
|
Set this to 0 if you don’t want |CtrlP| to search for dotfiles and dotdirs: >
|
||||||
let g:ctrlp_dotfiles = 1
|
let g:ctrlp_dotfiles = 1
|
||||||
@ -235,7 +240,7 @@ Examples: >
|
|||||||
\ 'file': '\.exe$\|\.so$\|\.dll$',
|
\ 'file': '\.exe$\|\.so$\|\.dll$',
|
||||||
\ 'link': 'some$\|bad$\|symbolic$\|links$',
|
\ 'link': 'some$\|bad$\|symbolic$\|links$',
|
||||||
\ }
|
\ }
|
||||||
>
|
<
|
||||||
|
|
||||||
*'g:ctrlp_highlight_match'*
|
*'g:ctrlp_highlight_match'*
|
||||||
Use this to enable/disable highlighting of the matched patterns and to specify
|
Use this to enable/disable highlighting of the matched patterns and to specify
|
||||||
@ -688,13 +693,6 @@ USER-CONFIGURATION *ctrlp-user-config*
|
|||||||
|
|
||||||
Some miscellaneous configurations:~
|
Some miscellaneous configurations:~
|
||||||
|
|
||||||
+) MRU ==> MRE (most-recently-entered): >
|
|
||||||
autocmd BufEnter,BufUnload * 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:
|
+) |g:ctrlp_user_command| config that makes use of your |wildignore| setting:
|
||||||
https://github.com/kien/ctrlp.vim/issues/70 by Rich Alesi
|
https://github.com/kien/ctrlp.vim/issues/70 by Rich Alesi
|
||||||
|
|
||||||
@ -741,6 +739,8 @@ Special thanks:~
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
CHANGELOG *ctrlp-changelog*
|
CHANGELOG *ctrlp-changelog*
|
||||||
|
|
||||||
|
+ New option: |g:ctrlp_mruf_last_entered| change MRU to recently-entered
|
||||||
|
|
||||||
Before 2012/01/15~
|
Before 2012/01/15~
|
||||||
|
|
||||||
+ New mapping: Switch <tab> and <s-tab>. <tab> is now used for completion
|
+ New mapping: Switch <tab> and <s-tab>. <tab> is now used for completion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user