Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vim 使NERDTree和CtrlP忽略顶级供应商目录_Vim - Fatal编程技术网

Vim 使NERDTree和CtrlP忽略顶级供应商目录

Vim 使NERDTree和CtrlP忽略顶级供应商目录,vim,Vim,我希望NERDTree和CtrlP都忽略(不显示也不索引)顶级供应商目录 < P>但是,我确实希望这两个插件(以及将来的任何东西)都能考虑那些不在项目顶层的供应商目录下的文件(例如APP/资产/ JavaScript /供应商)。 我的wildignore设置如下: wildignore+=*.o、*.obj、.git、*.rbc、*.class、.svn、coverage/*,供应商 这使得供应商目录无论在哪里都被忽略 你能推荐一个解决方案吗 谢谢。对于NERDTree,您需要将其添加到g:N

我希望NERDTree和CtrlP都忽略(不显示也不索引)顶级供应商目录

< P>但是,我确实希望这两个插件(以及将来的任何东西)都能考虑那些不在项目顶层的供应商目录下的文件(例如APP/资产/ JavaScript /供应商)。 我的wildignore设置如下:

wildignore+=*.o、*.obj、.git、*.rbc、*.class、.svn、coverage/*,供应商

这使得供应商目录无论在哪里都被忽略

你能推荐一个解决方案吗


谢谢。

对于NERDTree,您需要将其添加到
g:NERDTreeIgnore

:let g:NERDTreeIgnore=['\~$', 'vendor']
由于我不喜欢在
'wildignore'
和NERDTree中维护排除列表,因此我使用以下scriptlet从前者自动设置后者:

" Use the 'wildignore' and 'suffixes' settings for filtering out files.
function! s:FileGlobToRegexp( glob )
    " The matching is done against the sole file / directory name.
    if a:glob =~# '^\*\.'
        return '\.' . a:glob[2:] . '$'
    else
        return '^' . a:glob . '$'
    endif
endfunction
function! s:SuffixToRegexp( suffix )
    return escape(v:val, '.~') . "$"
endfunction
let g:NERDTreeIgnore =
\   map(split(&wildignore, ','), 's:FileGlobToRegexp(v:val)') +
\   map(split(&suffixes, ','), 's:SuffixToRegexp(v:val)')
delfunction s:SuffixToRegexp
delfunction s:FileGlobToRegexp

编辑

但是,这将全局过滤掉
供应商
目录。目前不可能仅对顶级执行此操作,因为NERDTree仅对文件的basename执行筛选器比较:

self.getLastPathComponent(0) =~# pat

将此添加到您的.vimrc:

let g:NERDTreeRespectWildIgnore = 1

谢谢你的剧本,但我不确定这是我需要的。我希望在顶层忽略供应商,但不要在底层忽略供应商。举一个具体的例子,在Rails项目中,有一个顶级供应商目录,其中包含我希望忽略的所有依赖项。在app/assets/javascripts/vendor中也可以有一个vendor文件夹,我希望NERDTree显示该文件夹并对其进行索引。与
'wildignore'
类似,NERDTree选项也是全局的(请参见我的编辑)。你必须修改插件才能得到你想要的。另请参见