Home

Awesome

Intro

util to make wildignore and similars more friendly and easier to config

if you like my work, check here for a list of my vim plugins, or buy me a coffee


NOTE: by default, this plugin would recognize .gitignore and modify wildignore, which may affect expand() glob() functions see #1 for more info


Usage

  1. Install

    Plug 'ZSaberLv0/ZFVimIgnore'
    
  2. make your plugin or configs adapt to ignore setting

    autocmd User ZFIgnoreOnUpdate let &wildignore = join(ZFIgnoreToWildignore(ZFIgnoreGet()), ',')
    autocmd User ZFIgnoreOnUpdate let g:NERDTreeIgnore = ZFIgnoreToRegexp(ZFIgnoreGet({
            \   'bin' : 0,
            \   'media' : 0,
            \ }))
    

    by default:

    • some common ignore are added
    • .gitignore under current dir and all parent dirs would be recognized
    • wildignore would be applied automatically
  3. you may add or remove custom ignore at runtime

    :ZFIgnoreAdd *.obj
    :ZFIgnoreRemove build
    

    supported patterns:

    • see :h wildcards
    • supported: ? * [abc]
    • not supported: ** */

    or completely enable or disable by :ZFIgnoreToggle

Typical config

here are some typical config for other plugins

" vim-easygrep
autocmd User ZFIgnoreOnUpdate let g:EasyGrepFilesToExclude = join(ZFIgnoreToWildignore(ZFIgnoreGet()), ',')

" LeaderF
function! s:ZFIgnore_LeaderF()
    let ignore = ZFIgnoreGet()
    let g:Lf_WildIgnore = {'file' : ignore['file'], 'dir' : ignore['dir']}
endfunction
autocmd User ZFIgnoreOnUpdate call s:ZFIgnore_LeaderF()

" NERDTree
let g:NERDTreeIgnore = ZFIgnoreToRegexp(ZFIgnoreGet({
        \   'bin' : 0,
        \   'media' : 0,
        \ }))

Ignore options

we have some builtin ignore options, and all of them are enabled by default:

all currently registered option can be checked and modified by g:ZFIgnoreOptionDefault

you can also supply custom ignore options, see below

For impl to extend ignore options

for impl:

" declare your option and default value
if !exists('g:ZFIgnoreOptionDefault')
    let g:ZFIgnoreOptionDefault = {}
endif
if !exists("g:ZFIgnoreOptionDefault['YourOptionName']")
    let g:ZFIgnoreOptionDefault['YourOptionName'] = 1
endif

" if the ignore item is simple
if !exists('g:ZFIgnoreData')
    let g:ZFIgnoreData = {}
endif
let g:ZFIgnoreData['YourImplName'] = {
        \   'common' : {
        \       'file' : {'*.obj':1, '*.bin':1},
        \       'dir' : {'build':1},
        \   },
        \   'YourOptionName' : {...},
        \ }

" if you want to implement more complex ignore detect at runtime
autocmd User ZFIgnoreOnSetup call YourSetup()
function! YourSetup()
    let g:ZFIgnoreData['YourImplName'] = {
            \   'common' : {
            \       'file' : {'*.obj':1, '*.bin':1},
            \       'dir' : {'build':1},
            \   },
            \   'YourOptionName' : {...},
            \ }
endfunction

for users:

" access ignore data as usual
let ignore = ZFIgnoreGet()

" or enable/disable by option name
let ignore = ZFIgnoreGet({'YourOptionName' : 1})

" or change default option
let g:ZFIgnoreOptionDefault['YourOptionName'] = 0
let ignore = ZFIgnoreGet()

FAQ