Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file_rec/git does not respect ignore_pattern and ignore_globs #886

Closed
laishulu opened this issue Mar 29, 2015 · 18 comments
Closed

file_rec/git does not respect ignore_pattern and ignore_globs #886

laishulu opened this issue Mar 29, 2015 · 18 comments

Comments

@laishulu
Copy link

  • Problems summary
    file_rec/git does not respect ignore_pattern and ignore_globs
  • Expected
    file that in git ls-files but ignored by "ignore_pattern" or "ignore_globs" should be ignored.
  • Environment Information
    • OS: OS X 10.10.3
    • Vim version: 7.4
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 23 2014 10:43:45)
MacOS X (unix) version
Included patches: 1-258
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +cmdline_info    +emacs_tags      -gettext         +lua             +mouse_urxvt     +profile         +statusline      +transparency    -X11
+arabic          +comments        +eval            -hangul_input    +menu            +mouse_xterm     +python          -sun_workshop    +user_commands   -xfontset
+autocmd         +conceal         +ex_extra        +iconv           +mksession       +multi_byte      -python3         +syntax          +vertsplit       +xim
+balloon_eval    +cryptv          +extra_search    +insert_expand   +modify_fname    +multi_lang      +quickfix        +tag_binary      +virtualedit     -xsmp
+browse          +cscope          +farsi           +jumplist        +mouse           -mzscheme        +reltime         +tag_old_static  +visual          -xterm_clipboard
++builtin_terms  +cursorbind      +file_in_path    +keymap          +mouseshape      +netbeans_intg   +rightleft       -tag_any_white   +visualextra     -xterm_save
+byte_offset     +cursorshape     +find_in_path    +langmap         +mouse_dec       +odbeditor       +ruby            +tcl             +viminfo         -xpm
+cindent         +dialog_con_gui  +float           +libcall         -mouse_gpm       +path_extra      +scrollbind      +terminfo        +vreplace
+clientserver    +diff            +folding         +linebreak       -mouse_jsbterm   +perl            +signs           +termresponse    +wildignore
+clipboard       +digraphs        -footer          +lispindent      +mouse_netterm   +persistent_undo +smartindent     +textobjects     +wildmenu
+cmdline_compl   +dnd             +fork()          +listcmds        +mouse_sgr       +postscript      -sniff           +title           +windows
+cmdline_hist    -ebcdic          +fullscreen      +localmap        -mouse_sysmouse  +printer         +startuptime     +toolbar         +writebackup
  • Minimal vimrc less than 50 lines
" Your vimrc
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
set wildignore=*.o,*.obj,*.la,*.lo,*.so,*.pyc,*.pyo,*.jpg,*.png,*.gif

      call unite#custom#source('file_rec/git', 'ignore_globs',
          \ split(&wildignore, ','))

      let dot = '\%(^\|/\)\.'
      let dirs = '\%(^\|/\)\%(' . join(
            \ ['node_modules', 'bower_components', 'dist'], '\|')
            \ . '\)\%($\|/\)'
      let files = join(['\.pyc\%($\)'], '\|')
      let pattern = join([dot, dirs, files], '\|')
      call unite#custom#source('file_rec/git', 'ignore_pattern', pattern)
  • Reproducable ways from Vim starting
    1. startup vim.
    2. jpg file should not presented when file_rec/git is invoked.
@Shougo
Copy link
Owner

Shougo commented Mar 29, 2015

OK. I will check it. But...
Please read the issue template.

#584

@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

Unfortunatelly, I cannot reproduce the problem. ignore_globs working.
But, Yes old version has problems.
Please upload unite.vim version.

@laishulu
Copy link
Author


  " Note: Skip initialization for vim-tiny or vim-small.
  if !1 | finish | endif

  if has('vim_starting')
    set nocompatible               " Be iMproved

    " Required:
    set runtimepath+=~/.vim/bundle/neobundle.vim/
  endif

  " Required:
  call neobundle#begin(expand('~/.vim/bundle/'))

  " Required:
  call neobundle#begin(expand('~/.vim/bundle/'))

  " Let NeoBundle manage NeoBundle
  " Required:
  NeoBundleFetch 'Shougo/neobundle.vim'

  " My Bundles here:
  " Refer to |:NeoBundle-examples|.
  " Note: You don't set neobundle setting in .gvimrc!

  call neobundle#end()

  " Required:
  filetype plugin indent on

  " If there are uninstalled bundles found on startup,
  " this will conveniently prompt you to install them.
  NeoBundleCheck

  NeoBundle 'Shougo/vimproc.vim', {
        \  'build' : {
        \    'windows' : 'make -f make_mingw32.mak',
        \    'cygwin' : 'make -f make_cygwin.mak',
        \    'mac' : 'make -f make_mac.mak',
        \    'unix' : 'make -f make_unix.mak',
        \  },
        \}
  NeoBundle 'Shougo/unite.vim' "{{{
    let bundle = neobundle#get('unite.vim')
    function! bundle.hooks.on_source(bundle)
      call unite#filters#matcher_default#use(['matcher_fuzzy'])
      call unite#filters#sorter_default#use(['sorter_rank'])
      call unite#custom#profile('files', 'context.smartcase', 1)
      call unite#custom#source('line,outline','matchers',['matcher_fuzzy'])

      set wildignore=*.o,*.obj,*.la,*.lo,*.so,*.pyc,*.pyo,*.jpg,*.png,*.gif
      call unite#custom#source('file_rec/git', 'ignore_globs',
          \ split(&wildignore, ','))

      let dot = '\%(^\|/\)\.'
      let dirs = '\%(^\|/\)\%(' . join(
            \ ['node_modules', 'bower_components', 'dist'], '\|')
            \ . '\)\%($\|/\)'
      let files = join(['\.pyc\%($\)'], '\|')
      let pattern = join([dot, dirs, files], '\|')
      call unite#custom#source('file_rec/git', 'ignore_pattern', pattern)
    endfunction

    let g:unite_data_directory='~/.vim/.cache/unite'
    let g:unite_enable_start_insert=1
    let g:unite_source_history_yank_enable=1
    let g:unite_source_rec_max_cache_files=5000

    if executable('ag')
      let g:unite_source_grep_command='ag'
      let g:unite_source_grep_default_opts ='--nocolor --nogroup' .
            \' --ignore "node_modules"' .
            \' --ignore "bower_components"'
      let g:unite_source_grep_recursive_opt=''
    endif

    function! s:unite_settings()
      nmap <buffer> Q <plug>(unite_exit)
      nmap <buffer> <esc> <plug>(unite_exit)
      imap <buffer> <esc> <plug>(unite_exit)
    endfunction
    autocmd FileType unite call s:unite_settings()

    nmap <space> [unite]
    nnoremap [unite] <nop>

    " current dir(c: current dir)
    nnoremap <silent> [unite]c :<C-u>UniteWithCurrentDir -buffer-name=files -no-split
          \ file_point buffer bookmark file_rec/git file/new<CR>
    " buffer dir(b: buffer dir)
    nnoremap <silent> [unite]b :<C-u>UniteWithBufferDir -buffer-name=files -no-split
          \ file_point buffer bookmark file_rec/git file/new<CR>
    " fuzzy find bookmark/file/buffer(f: find)
    nnoremap <silent> [unite]f :<C-u>Unite -buffer-name=files -no-split
          \ file_point buffer bookmark file_rec/git file/new<CR>

For this full .vimrc file with the latest version of unite after I runned NeobundleInstall, the problem is still there

When I type <space> f in some git directory, I still can see .png files

@laishulu laishulu reopened this Mar 31, 2015
@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

Please upload your unite.vim version.
Unite.vim has some fixes for ignore_globs.

@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

startup vim.
jpg file should not presented when file_rec/git is invoked.

I tested your minimal .vimrc, but jpg files are not presented.
It is filtered by "ignore_globs".

@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

@chenhouwu Please upload your png file extensions.

@laishulu
Copy link
Author

qq20150331-1

@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

Please upload your unite.vim version.

@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

@chenhouwu Please check the function in your unite.vim/candidates.vim.

function! s:ignore_candidates(candidates, context) "{{{
  let candidates = copy(a:candidates)

  if a:context.ignore_pattern != ''
    let candidates = unite#filters#vim_filter_pattern(
          \   candidates, a:context.ignore_pattern)
  endif

  if !empty(a:context.ignore_globs)
    let candidates = unite#filters#filter_patterns(candidates,
          \ unite#filters#globs2patterns(a:context.ignore_globs),
          \ unite#filters#globs2patterns(a:context.white_globs))
  endif

  if a:context.path != ''
    let candidates = unite#filters#{unite#util#has_lua()? 'lua' : 'vim'}
          \_filter_head(candidates, a:context.path)
  endif

  return candidates
endfunction"}}}

Please upload unite#filters#globs2patterns(a:context.ignore_globs) result in the function.

@laishulu
Copy link
Author

candidates:

[file_rec/git] directory: /Users/chw/tmp
[]
[{'word': '/Users/chw/tmp/a.jpg', 'action__path': '/Users/chw/tmp/a.jpg'}, {'word': '/Users/chw/tmp/a.png', 'action__path': '/Users/chw/tmp/a.png'}]

@Shougo
Copy link
Owner

Shougo commented Mar 31, 2015

Please upload unite#filters#globs2patterns(a:context.ignore_globs) result in the function.

Not candidates value.

@laishulu
Copy link
Author

laishulu commented Apr 1, 2015

unite#filters#globs2patterns(a:context.ignore_globs) is shown as bellow.

[file_rec/git] directory: /Users/chw/tmp
['/%.$', '/[^/]*~$', '/[^/]*%.o$', '/[^/]*%.exe$', '/[^/]*%.bak$', '/ds_store$', '/[^/]*%.pyc$', '/[^/]*%.sw[po]$', '/[^/]*%.class$', '/%.hg/.*$', '/%.git/.*$', '/%.bzr/.*$', '/%
.svn/.*$', '/tags$', '/tags%-[^/]*$']
['/%.$', '/[^/]*~$', '/[^/]*%.o$', '/[^/]*%.exe$', '/[^/]*%.bak$', '/ds_store$', '/[^/]*%.pyc$', '/[^/]*%.sw[po]$', '/[^/]*%.class$', '/%.hg/.*$', '/%.git/.*$', '/%.bzr/.*$', '/%
.svn/.*$', '/tags$', '/tags%-[^/]*$']
[]
Press ENTER or type command to continue

seems s:ignore_candidates(candidates, context) is executed three times, and at the last time, it's cleared to blank.

@Shougo
Copy link
Owner

Shougo commented Apr 1, 2015

OK. I get it.

function! bundle.hooks.on_source(bundle) is not executed.
You must call call neobundle#end() after :NeoBundle lines.

@Shougo
Copy link
Owner

Shougo commented Apr 1, 2015

Your .vimrc is broken. Corrected version is here:

  " Note: Skip initialization for vim-tiny or vim-small.
  if !1 | finish | endif

  if has('vim_starting')
    set nocompatible               " Be iMproved

    " Required:
    set runtimepath+=~/.vim/bundle/neobundle.vim/
  endif

  " Required:
  call neobundle#begin(expand('~/.vim/bundle/'))

  " Let NeoBundle manage NeoBundle
  " Required:
  NeoBundleFetch 'Shougo/neobundle.vim'

  " My Bundles here:
  " Refer to |:NeoBundle-examples|.
  " Note: You don't set neobundle setting in .gvimrc!

  NeoBundle 'Shougo/vimproc.vim', {
        \  'build' : {
        \    'windows' : 'make -f make_mingw32.mak',
        \    'cygwin' : 'make -f make_cygwin.mak',
        \    'mac' : 'make -f make_mac.mak',
        \    'unix' : 'make -f make_unix.mak',
        \  },
        \}
  NeoBundle 'Shougo/unite.vim' "{{{
    let bundle = neobundle#get('unite.vim')
    function! bundle.hooks.on_source(bundle)
      call unite#filters#matcher_default#use(['matcher_fuzzy'])
      call unite#filters#sorter_default#use(['sorter_rank'])
      call unite#custom#profile('files', 'context.smartcase', 1)
      call unite#custom#source('line,outline','matchers',['matcher_fuzzy'])

      set wildignore=*.o,*.obj,*.la,*.lo,*.so,*.pyc,*.pyo,*.jpg,*.png,*.gif
      call unite#custom#source('file_rec/git', 'ignore_globs',
          \ split(&wildignore, ','))

      let dot = '\%(^\|/\)\.'
      let dirs = '\%(^\|/\)\%(' . join(
            \ ['node_modules', 'bower_components', 'dist'], '\|')
            \ . '\)\%($\|/\)'
      let files = join(['\.pyc\%($\)'], '\|')
      let pattern = join([dot, dirs, files], '\|')
      call unite#custom#source('file_rec/git', 'ignore_pattern', pattern)
    endfunction

    let g:unite_data_directory='~/.vim/.cache/unite'
    let g:unite_enable_start_insert=1
    let g:unite_source_history_yank_enable=1
    let g:unite_source_rec_max_cache_files=5000

    if executable('ag')
      let g:unite_source_grep_command='ag'
      let g:unite_source_grep_default_opts ='--nocolor --nogroup' .
            \' --ignore "node_modules"' .
            \' --ignore "bower_components"'
      let g:unite_source_grep_recursive_opt=''
    endif

    function! s:unite_settings()
      nmap <buffer> Q <plug>(unite_exit)
      nmap <buffer> <esc> <plug>(unite_exit)
      imap <buffer> <esc> <plug>(unite_exit)
    endfunction
    autocmd FileType unite call s:unite_settings()

    nmap <space> [unite]
    nnoremap [unite] <nop>

    " current dir(c: current dir)
    nnoremap <silent> [unite]c :<C-u>UniteWithCurrentDir -buffer-name=files -no-split
          \ file_point buffer bookmark file_rec/git file/new<CR>
    " buffer dir(b: buffer dir)
    nnoremap <silent> [unite]b :<C-u>UniteWithBufferDir -buffer-name=files -no-split
          \ file_point buffer bookmark file_rec/git file/new<CR>
    " fuzzy find bookmark/file/buffer(f: find)
    nnoremap <silent> [unite]f :<C-u>Unite -buffer-name=files -no-split
          \ file_point buffer bookmark file_rec/git file/new<CR>


  call neobundle#end()

  " Required:
  filetype plugin indent on

  " If there are uninstalled bundles found on startup,
  " this will conveniently prompt you to install them.
  NeoBundleCheck

@laishulu
Copy link
Author

laishulu commented Apr 1, 2015

disaster after I move call neobundle#end() to the end of the file, I got

E185: Cannot find color scheme 'solarized'

But, now the ignore works :-)

I have the following between call neobundle#begin(expand('~/.vim/bundle/')), call neobundle#end()

  NeoBundle 'altercation/vim-colors-solarized'
    set background=dark
    colorscheme solarized

@laishulu
Copy link
Author

laishulu commented Apr 1, 2015

after I move the following lines after call neobundle#end(), then all is OK

set background=dark
colorscheme solarized

But it's ugly, because I want theme related config to sit together.
Any solution?

I've tried to invoke an additional call neobundle#end() twice(one for solarized, the othe for unite), but the later one has no effect.

@Shougo
Copy link
Owner

Shougo commented Apr 1, 2015

But it's ugly, because I want theme related config to sit together.
Any solution?

You should use force.

NeoBundle 'altercation/vim-colors-solarized', {'force':1}

@Shougo Shougo closed this as completed Apr 1, 2015
@laishulu
Copy link
Author

laishulu commented Apr 1, 2015

works, thanks for your warm help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants