Option to use the ignore options for g:ctrlp_user_command

* Not recommended as it'll likely increase the total indexing time and defeat
  the purpose of using custom commands, but should be an option for convenience.
  Also, mention the default (of not applying ignore options) more explicitly
  in the docs to reduce the number of unnecessary bug reports.

* Add a note about E706.
This commit is contained in:
Kien N 2012-08-07 10:19:57 +07:00
parent 6ddbfe2cc0
commit 093b1c2325
3 changed files with 66 additions and 36 deletions

View File

@ -8,26 +8,26 @@
" ** Static variables {{{1 " ** Static variables {{{1
fu! s:ignore() "{{{2 fu! s:ignore() "{{{2
let igdirs = [ let igdirs = [
\ '\.git$', \ '\.git',
\ '\.hg$', \ '\.hg',
\ '\.svn$', \ '\.svn',
\ '_darcs$', \ '_darcs',
\ '\.bzr$', \ '\.bzr',
\ '\.cdv$', \ '\.cdv',
\ '\~\.dep$', \ '\~\.dep',
\ '\~\.dot$', \ '\~\.dot',
\ '\~\.nib$', \ '\~\.nib',
\ '\~\.plst$', \ '\~\.plst',
\ '\.pc$', \ '\.pc',
\ '_MTN$', \ '_MTN',
\ '<blib$', \ '<blib',
\ '<CVS$', \ '<CVS',
\ '<RCS$', \ '<RCS',
\ '<SCCS$', \ '<SCCS',
\ '_sgbak$', \ '_sgbak',
\ '<autom4te\.cache$', \ '<autom4te\.cache',
\ '<cover_db$', \ '<cover_db',
\ '_build$', \ '_build',
\ ] \ ]
let igfiles = [ let igfiles = [
\ '\~$', \ '\~$',
@ -45,7 +45,7 @@ fu! s:ignore() "{{{2
\ '\.tar\.gz$', \ '\.tar\.gz$',
\ ] \ ]
retu { retu {
\ 'dir': '\v'.join(igdirs, '|'), \ 'dir': '\v('.join(igdirs, '|').')($|[\/])',
\ 'file': '\v'.join(igfiles, '|'), \ 'file': '\v'.join(igfiles, '|'),
\ } \ }
endf "}}}2 endf "}}}2
@ -347,6 +347,14 @@ fu! s:UserCmd(lscmd)
if exists('s:vcscmd') && s:vcscmd if exists('s:vcscmd') && s:vcscmd
cal map(g:ctrlp_allfiles, 'tr(v:val, "/", "\\")') cal map(g:ctrlp_allfiles, 'tr(v:val, "/", "\\")')
en en
if type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore']
if !empty(s:usrign)
let g:ctrlp_allfiles = ctrlp#dirnfile(g:ctrlp_allfiles)[1]
en
if &wig != ''
cal filter(g:ctrlp_allfiles, 'glob(v:val) != ""')
en
en
endf endf
fu! s:lsCmd() fu! s:lsCmd()
@ -359,12 +367,15 @@ fu! s:lsCmd()
en en
let s:vcscmd = s:lash == '\' ? 1 : 0 let s:vcscmd = s:lash == '\' ? 1 : 0
retu cmd[1] retu cmd[1]
elsei type(cmd) == 4 && has_key(cmd, 'types') elsei type(cmd) == 4 && ( has_key(cmd, 'types') || has_key(cmd, 'fallback') )
let fndroot = []
if has_key(cmd, 'types') && cmd['types'] != {}
let [markrs, cmdtypes] = [[], values(cmd['types'])] let [markrs, cmdtypes] = [[], values(cmd['types'])]
for pair in cmdtypes for pair in cmdtypes
cal add(markrs, pair[0]) cal add(markrs, pair[0])
endfo endfo
let fndroot = s:findroot(s:dyncwd, markrs, 0, 1) let fndroot = s:findroot(s:dyncwd, markrs, 0, 1)
en
if fndroot == [] if fndroot == []
retu has_key(cmd, 'fallback') ? cmd['fallback'] : '' retu has_key(cmd, 'fallback') ? cmd['fallback'] : ''
en en

View File

@ -226,14 +226,22 @@ CtrlP to not show. Use regexp to specify the patterns: >
let g:ctrlp_custom_ignore = '' let g:ctrlp_custom_ignore = ''
< <
Examples: > Examples: >
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' let g:ctrlp_custom_ignore = '\v(\.git|\.hg|\.svn)($|[\/])'
let g:ctrlp_custom_ignore = { let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$', \ 'dir': '\v(\.git|\.hg|\.svn)($|[\/])',
\ 'file': '\.exe$\|\.so$\|\.dll$', \ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS', \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
\ } \ }
let g:ctrlp_custom_ignore = {
\ 'file': '\v(\.cpp|\.h|\.hh|\.cxx)@<!$'
\ }
< <
Note: ignoring only applies when |globpath()| is used to scan for files. 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
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.
*'g:ctrlp_max_files'* *'g:ctrlp_max_files'*
The maximum number of files to scan, set to 0 for no limit: > The maximum number of files to scan, set to 0 for no limit: >
@ -268,7 +276,8 @@ when scanning large projects: >
\ 1: [root_marker_1, listing_command_1], \ 1: [root_marker_1, listing_command_1],
\ n: [root_marker_n, listing_command_n], \ n: [root_marker_n, listing_command_n],
\ }, \ },
\ 'fallback': fallback_command \ 'fallback': fallback_command,
\ 'ignore': 0 or 1
\ } \ }
< <
Examples: > Examples: >
@ -279,11 +288,20 @@ Examples: >
\ 1: ['.git', 'cd %s && git ls-files'], \ 1: ['.git', 'cd %s && git ls-files'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'], \ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ }, \ },
\ 'fallback': 'find %s -type f' \ 'fallback': 'find %s -type f',
\ 'ignore': 0
\ } \ }
< <
If the fallback_command is empty or not defined, |globpath()| will then be used Note #1: if the fallback_command is empty or not defined, |globpath()| will
when searching outside a repo. then be used when searching outside a repo.
Note #2: unless the |Dictionary| format is used and 'ignore' is defined and set
to 1, the |wildignore| and |g:ctrlp_custom_ignore| options do not apply when
these custom commands are being used. When not defined, 'ignore' is set to 0 by
default to retain the performance advantage of using external commands.
Note #3: when changing the option's variable type, remember to |:unlet| it
first or restart Vim to avoid the "E706: Variable type mismatch" error.
*'g:ctrlp_max_history'* *'g:ctrlp_max_history'*
The maximum number of input strings you want CtrlP to remember. The default The maximum number of input strings you want CtrlP to remember. The default
@ -1113,6 +1131,7 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
+ New key for |g:ctrlp_user_command| when it's a Dictionary: 'ignore'.
+ New options: |g:ctrlp_open_func|. + New options: |g:ctrlp_open_func|.
|g:ctrlp_tabpage_position|. |g:ctrlp_tabpage_position|.

View File

@ -62,9 +62,9 @@ Use `:difft` when opening multiple files to run `:difft` on the first 4 files.
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=tmp\*,*.swp,*.zip,*.exe " Windows set wildignore+=tmp\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' let g:ctrlp_custom_ignore = '\v(\.git|\.hg|\.svn)($|[\/])'
let g:ctrlp_custom_ignore = { let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$', \ 'dir': '\v(\.git|\.hg|\.svn)($|[\/])',
\ 'file': '\.exe$\|\.so$\|\.dll$', \ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'some_bad_symbolic_links', \ 'link': 'some_bad_symbolic_links',
\ } \ }