Shougo / unite.vim

:dragon: Unite and create user interfaces
http://www.vim.org/scripts/script.php?script_id=3396
Other
2.85k stars 223 forks source link

Optimize Unite for the home directory and other general scenarios ? #644

Closed nishantvarma closed 10 years ago

nishantvarma commented 10 years ago

Unite is really good ! Thats an excellent job there .

However few scenarios I find a usability issue over CtrlP as a newbie :

1)In the Home Directory , it doesn't show up some files as expected , though it does show many directories especially hidden ones (which is fine ) . For example I search for work and I have a ~/work.markdown Unite won't show it , though it does show something like ~Programming/linux/.config_data/filenamework .

2) Also I feel that in some cases Unite's fuzzy takes precedence over a direct match . Like I search for 'script' and dir/job/programs/cron/inside/pub matches but dir/script is not matching until I go further down the search ..... I feel a direct match should take precedence .

Are there any tips to make this better ?

Here is my unite setting :

" Use ag for Search
if executable('ag')
  let g:unite_source_grep_command = 'ag'
  let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
  let g:unite_source_grep_recursive_opt = ''
endif
call unite#custom_source('file_rec,file_rec/async,file_mru,file,buffer,grep',
      \ 'ignore_pattern', join([
      \ '\.git/',
      \ ], '\|'))
let g:unite_enable_start_insert = 1
let g:unite_split_rule = "botright"
let g:unite_force_overwrite_statusline = 0
let g:unite_winheight = 10
let g:unite_source_history_yank_enable = 1
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
call unite#custom#source('file_rec/async','sorters','sorter_rank')
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
  let b:SuperTabDisabled=1
  imap <buffer> <C-j>   <Plug>(unite_select_next_line)
  imap <buffer> <C-k>   <Plug>(unite_select_previous_line)
  imap <silent><buffer><expr> <C-x> unite#do_action('split')
  imap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
  imap <silent><buffer><expr> <C-t> unite#do_action('tabopen')

  nmap <buffer> <ESC> <Plug>(unite_exit)
endfunction
Shougo commented 10 years ago

1)In the Home Directory , it doesn't show up some files as expected , though it does show many directories especially hidden ones (which is fine ) . For example I search for work and I have a ~/work.markdown Unite won't show it , though it does show something like ~Programming/linux/.config_data/filenamework .

Q: file_rec and file_rec/async cannot find all files.
https://github.com/Shougo/unite.vim/issues/356
https://github.com/Shougo/unite.vim/issues/370
https://github.com/Shougo/unite.vim/issues/459

A: It is a feature.  cf: |g:unite_source_rec_max_cache_files|.
And the default max candidates are limited. You can customize it by
|unite#custom#source()|. >
    let g:unite_source_rec_max_cache_files = 0
    call unite#custom#source('file_rec,file_rec/async',
    \ 'max_candidates', 0)
Shougo commented 10 years ago

2) Also I feel that in some cases Unite's fuzzy takes precedence over a direct match . Like I search for 'script' and dir/job/programs/cron/inside/pub matches but dir/script is not matching until I go further down the search ..... I feel a direct match should take precedence .

It is "sorter_rank" feature. I think your configuration is wrong.

In 2 problem, you should read template and create minimal .vimrc.

https://github.com/Shougo/unite.vim/issues/584

nishantvarma commented 10 years ago

Alright thanks ! I will go over the help on Unite and get back if any issues on that .

Shougo commented 10 years ago

http://gyazo.com/914f6316a71914db48b2f4229425995f

My suggestion is correct.

nishantvarma commented 10 years ago

I have this

nnoremap <C-P> :Unite -buffer-name=files file_rec/async:!<CR>

Problem:

I work with multiple projects like foo (/home/programming/foo/.git ) and bar ( /optimization/bar/.git) totally unrelated but happen to be under git version control .

Now suppose I opened a single Vim session and :

I am in any file like /home/programming/foo/something/test.c and now when I hit a Ctrl-P I would like Unite.vim is to search for a file recursively with foo/.git as the root directory . It should detect this root directory .

I am in the buffer /optimization/bar/hello/cool.py , now when I hit a Ctrl-P I would like Unite.vim to search for the file recursively WITH bar/.git as the project root directory .

Vim Solution

autocmd BufEnter * silent! lcd %:p:h works for me and I have no problem switching directory to the buffer directory usually .

Unite Solutions ?

Can I make it work from the current directory or the nearest .git that is available . Things like UniteWithProjectDir or UniteWithBufferDir didn't help when I had file_rec . Ctrl-P usually does that by default , in Unite how can I achieve this ? Can you please let me know and is it in the FAQ already ?

Thanks

Shougo commented 10 years ago

I don't understand your problem. Please explain it by example.

I think :UniteWithBufferDir is better solution.

nishantvarma commented 10 years ago

I edited it , do read it when you have time .

But my question boils down to this as I also expect :UniteWithBufferDir to work !!

:UniteWithBufferDir file_rec I expect it will recursively search from the the current buffer's directory and not the :pwd set in Vim when 2 different files are opened . I see :UniteWithBufferDir file_rec giving same result in both buffers at different locations in FS and the result is same as :UniteWithCurrentDir file_rec

Shougo commented 10 years ago

OK. I get it. But in my environment, :UniteWithBufferDir is works.

Please read issue template and upload reproducable ways.

https://github.com/Shougo/unite.vim/issues/584

nishantvarma commented 10 years ago

Problems summary

:UniteWithBufferDir file_rec opens recursive from ~

Expected

Should work From current buffers path like :UniteWithBufferDir file . Shoud work recursively from the current buffer directory .

Environment Information

OS:Centos 6.5 Vim version:Vim 7.4.307

Minimal vimrc less than 50 lines

"Requires Pathogen

execute pathogen#infect() Helptags syntax on filetype plugin indent on set shiftwidth=4

" Unite

let g:unite_data_directory='~/.unite/.cache/' let g:unite_split_rule = "botright" let g:unite_source_file_rec_max_cache_files = 3000 let g:unite_enable_start_insert = 1 let g:unite_force_overwrite_statusline = 0 let g:unite_winheight = 10 let g:unite_source_history_yank_enable = 1 let g:unite_prompt='» ' if executable('ag') " Use ag for Search let g:unite_source_grep_command = 'ag' let g:unite_source_grep_default_opts = '--nogroup --nocolor -S -C4' let g:unite_source_grep_recursive_opt = '' endif call unite#filters#matcher_default#use(['matcher_fuzzy']) call unite#filters#sorter_default#use(['sorter_rank']) call unite#custom#profile('files', 'filters', 'sorter_rank') call unite#custom#source('file_mru,file_rec,file_rec/async,grepocate', \ 'max_candidates', 3000) call unite#custom_source('file_rec,file_rec/async,file_mru,file,buffer,grep', \ 'ignore_pattern', join([ \ '.git/', \ ], '|'))

Reproducable ways from Vim starting

0.startup vim from ~

  1. Open any 2 files from 2 different Git Version directories
  2. :UniteWithBufferDir file_rec in either directories

I see it coming from Home (~) Regargless in either buffers .

Shougo commented 10 years ago

Thanks. Fixed.

nishantvarma commented 10 years ago

Ok Thanks !