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

View File

@ -226,14 +226,22 @@ CtrlP to not show. Use regexp to specify the patterns: >
let g:ctrlp_custom_ignore = ''
<
Examples: >
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
let g:ctrlp_custom_ignore = '\v(\.git|\.hg|\.svn)($|[\/])'
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'dir': '\v(\.git|\.hg|\.svn)($|[\/])',
\ 'file': '\.exe$\|\.so$\|\.dll$',
\ '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'*
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],
\ n: [root_marker_n, listing_command_n],
\ },
\ 'fallback': fallback_command
\ 'fallback': fallback_command,
\ 'ignore': 0 or 1
\ }
<
Examples: >
@ -279,11 +288,20 @@ Examples: >
\ 1: ['.git', 'cd %s && git ls-files'],
\ 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
when searching outside a repo.
Note #1: if the fallback_command is empty or not defined, |globpath()| will
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'*
The maximum number of input strings you want CtrlP to remember. The default
@ -1113,6 +1131,7 @@ Special thanks:~
===============================================================================
CHANGELOG *ctrlp-changelog*
+ New key for |g:ctrlp_user_command| when it's a Dictionary: 'ignore'.
+ New options: |g:ctrlp_open_func|.
|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\*,*.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 = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'dir': '\v(\.git|\.hg|\.svn)($|[\/])',
\ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'some_bad_symbolic_links',
\ }