" ----------------------------------------------------------- " unite.vim " 起動時にインサートモードで開始 let mapleader = "\" let g:unite_enable_start_insert = 1 let g:unite_source_file_mru_limit = 5000 let g:unite_update_time=10 let g:unite_source_file_rec_max_cache_files = 20000 let g:unite_source_rec_min_cache_files = 1000 if has("mac") elseif has("win64") endif " Ignore build directories call unite#custom_source('file_rec,file_rec/async,file_mru,file,buffer,grep', \ 'ignore_pattern', join([ \ '\.git/', \ '\/*build*', \ '\target/', \ 'node_modules/', \ ], '\|')) " Search let g:unite_source_grep_max_candidates = 2000 let g:unite_source_find_max_candidates = 2000 " 高速化 let g:unite_source_file_mru_filename_format = '' let s:pat = '\v' . join([ \ '\~$', \ '\.%(o|exe|dll|bak|DS_Store|zwc|pyc|sw[po]|class|meta)$', \ '%(^|[/\\])%(\.|\.hg|\.git|\.bzr|\.svn|tags%(-.*)?)%($|[/\\])$', \ '\.bundle/', 'vendor/', \ ], '|') let g:unite_source_alias_aliases = { \ 'proj_mru': { \ 'source': 'file_mru', \ } \ } call unite#custom#source('file', 'ignore_pattern', \ '/\.\%(svn\|/\)\?$\|/tags\%(-..\)\?$\|\.meta$') call unite#custom#source('file', 'ignore_globs', []) call unite#custom#source('file_rec', 'ignore_pattern', s:pat) call unite#custom#source('file_rec/async', 'ignore_pattern', s:pat) call unite#custom#source('file_rec/git', 'ignore_pattern', s:pat) call unite#custom#source('proj_mru', 'matchers', \ ['matcher_project_files', 'matcher_default']) call unite#custom#source('proj_mru', 'converters', \ ['converter_relative_word']) let s:unite_default_options = { \ 'update_time': 50, \ 'start_insert': 1, \ } call unite#custom#profile('default', 'context', s:unite_default_options) let g:unite_source_rec_max_cache_files = 100000 " アウトライン nnoremap o :CloseSomeWindow \ (index(['qf','unite','vimtest','taglist'], getwinvar(v:val,'&filetype')) != -1) \ \|\| (getwinvar(v:val, '&filetype') ==# 'help' \ && !getwinvar(v:val, '&modifiable')):Unite outline -start-insert nnoremap O :CloseSomeWindow \ (index(['qf','unite','vimtest','taglist'], getwinvar(v:val,'&filetype')) != -1) \ \|\| (getwinvar(v:val, '&filetype') ==# 'help' \ && !getwinvar(v:val, '&modifiable')):Unite -no-quit -vertical -start-insert -winwidth=30 outline let g:unite_source_outline_filetype_options = { \ '*': { \ 'auto_update': 1, \ 'auto_update_event': 'write', \ }, \ 'cpp': { \ 'auto_update': 0, \ }, \ 'javascript': { \ 'ignore_types': ['comment'], \ }, \} " grep nnoremap g :Unite vimgrep " grep検索 nnoremap ,g :CdCurrent:Unite grep:. -buffer-name=search-buffer " ディレクトリを指定してgrep検索 nnoremap ,dg :Unite grep -buffer-name=search-buffer nnoremap ,R :UniteResume search-buffer if executable('pt') let g:unite_source_grep_command = 'pt' let g:unite_source_grep_default_opts = '--nogroup --nocolor' let g:unite_source_grep_recursive_opt = '' let g:unite_source_grep_encoding = 'utf-8' endif " mark let g:unite_source_mark_marks = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' " ctag nnoremap ,ut :Unite tag -start-insert " 常用セット nnoremap :CloseSomeWindow \ (index(['qf','unite','vimtest','taglist'], getwinvar(v:val,'&filetype')) != -1) \ \|\| (getwinvar(v:val, '&filetype') ==# 'help' \ && !getwinvar(v:val, '&modifiable')):Unite -silent -start-insert buffer nnoremap :Unite -silent buffer file_mru nnoremap :CloseSomeWindow \ (index(['qf','unite','vimtest','taglist'], getwinvar(v:val,'&filetype')) != -1) \ \|\| (getwinvar(v:val, '&filetype') ==# 'help' \ && !getwinvar(v:val, '&modifiable'))mT:Unite -silent -start-insert buffer file_mru " call unite#custom#source('file,file/new,file_mru,buffer,file_rec', " \ 'matchers', 'matcher_fuzzy') autocmd MyAutoCmd FileType help,qf nnoremap " yankround nnoremap y :Unite yankround -start-insert " " ref/php " nnoremap ,up :Unite ref/phpmanual " bookmark nnoremap b :Unite bookmark -start-insert if has("mac") else let g:unite_source_bookmark_directory = "c:/tools/vim/bookmark" endif "call unite#custom_default_action('source/bookmark/directory' , 'vimfiler') " command history nnoremap h mT:Unite history/command -start-insert " help nnoremap H :Unite help " file nnoremap F :CdCurrent:Unite file -buffer-name=files -start-insert " nnoremap f :Unite file_rec/async -buffer-name=files -start-insert " " code change history " nnoremap j :Unite jump -start-insert " tab " nnoremap T :Unite tab -start-insert " source nnoremap us :Unite source " ctag " nnoremap uT :Unite tag nnoremap l :Unite -buffer-name=search line -start-insert call unite#custom#source('line', 'matchers', 'matcher_vigemo') " 3文字入力した時から絞り込みを開始する let g:unite#filters#matcher_vigemo#filtering_input_length = 4 " unite.vimのマッチャ設定 call unite#custom#source('grep', 'matchers', 'matcher_fuzzy') call unite#custom#source('history/command', 'matchers', 'matcher_fuzzy') " call unite#custom#source('file', 'matchers', 'matcher_vigemo') " call unite#custom#source('line', 'matchers', 'matcher_vigemo') " call unite#custom#source('yankround', 'matchers', 'matcher_vigemo') " call unite#custom#source('outline', 'matchers', 'matcher_vigemo') " call unite#custom#source('neomru/file', 'matchers', 'matcher_vigemo') " call unite#custom#source('outline', 'syntax', 'shd') " call unite#custom#source('toggl/task', 'matchers', 'matcher_vigemo') " unite.vim上でのキーマッピング autocmd FileType unite call s:unite_my_settings() function! s:unite_my_settings() " 単語単位からパス単位で削除するように変更 imap (unite_delete_backward_path) " ESCキーを2回押すと終了する nmap q imap q endfunction let g:unite_source_outline_indent_width = 0 let g:unite_source_outline_filetype_options = { \ '*': { \ 'auto_update': 1, \ 'auto_update_event': 'hold', \ }, \ 'cpp': { \ 'auto_update': 0, \ }, \ 'javascript': { \ 'ignore_types': ['comment'], \ }, \ 'markdown': { \ 'auto_update_event': 'hold', \ }, \} augroup myuniteautocmd autocmd! augroup END autocmd myuniteautocmd FileType unite call s:my_unite_settings() function! s:my_unite_settings() imap (unite_exit) imap (unite_delete_backward_path) map (unite_exit) noremap s unite#smart_map("s", unite#do_action('right')) noremap S unite#smart_map("S", unite#do_action('split')) noremap n unite#smart_map("n", unite#do_action('insert')) noremap f unite#smart_map("f", unite#do_action('vimfiler')) noremap F unite#smart_map("f", unite#do_action('tabvimfiler')) imap (unite_select_next_line) imap unite#do_action('split') imap unite#do_action('vsplit') imap jj (unite_insert_leave) imap j unite#smart_map('j', '') nmap (unite_loop_cursor_down) nmap (unite_loop_cursor_up) map (unite_rotate_next_source) map (unite_rotate_previous_source) imap (unite_insert_leave) inoremap unite#do_action('tabopen') nnoremap unite#do_action('tabopen') inoremap unite#do_action('yank') nnoremap unite#do_action('yank') inoremap unite#do_action('preview') nnoremap unite#do_action('preview') inoremap unite#do_action('rec') nnoremap unite#do_action('rec') inoremap unite#do_action('create') nnoremap unite#do_action('create') inoremap unite#do_action('vsplit') nnoremap unite#do_action('vsplit') endfunction " project let $JVGREP_OUTPUT_ENCODING = 'sjis' set grepprg=jvgrep let g:unite_source_rec_async_command=['pt', '--nocolor', '--nogroup', '-g', '.'] nnoremap P :CloseSomeWindow \ (index(['qf','unite','vimtest','taglist'], getwinvar(v:val,'&filetype')) != -1) \ \|\| (getwinvar(v:val, '&filetype') ==# 'help' \ && !getwinvar(v:val, '&modifiable')):call Unite_project_files('-start-insert -auto-preview') function! Unite_project_files(options) cd c:/vagrant let b:projectlocal_root_dir = '' if exists('b:projectlocal_root_dir') echo b:projectlocal_root_dir execute ':Unite file_rec:' . ' -start-insert' " execute ':Unite file_rec/async:' . b:projectlocal_root_dir . ' ' . a:options else echo "You are not in any project." endif endfunction nnoremap p :CloseSomeWindow \ (index(['qf','unite','vimtest','taglist'], getwinvar(v:val,'&filetype')) != -1) \ \|\| (getwinvar(v:val, '&filetype') ==# 'help' \ && !getwinvar(v:val, '&modifiable')):call Unite_project_grep('-start-insert') function! Unite_project_grep(options) let b:projectlocal_root_dir = 'c:/vagrant/web/stg-m39_app' cd c:/vagrant if exists('b:projectlocal_root_dir') execute ':Unite grep:' . '.' . ' -no-quit ' . a:options " execute ':Unite grep:' . b:projectlocal_root_dir . ' ' . a:options else echo "You are not in any project." endif endfunction