Skip to content

Instantly share code, notes, and snippets.

@qickstarter
Created October 1, 2012 03:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qickstarter/3809378 to your computer and use it in GitHub Desktop.
Save qickstarter/3809378 to your computer and use it in GitHub Desktop.
"------------------------------------
" VimFiler
"------------------------------------
" 起動コマンド
" default <leader><leader>
nnoremap <Leader><leader> :VimFilerBufferDir<CR>
" nnoremap <C-H><C-F> :VimFilerExplorer<CR>
nnoremap <C-H><C-F> :call VimFilerExplorerGit()<CR>
" lean more [ utf8 glyph ]( http://sheet.shiar.nl/unicode )
let g:vimfiler_safe_mode_by_default = 0
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_sort_type = "filename"
" let g:vimfiler_split_action = "right"
" let g:vimfiler_edit_action = "open"
let g:vimfiler_preview_action = ""
let g:vimfiler_max_directories_history = 100
let g:vimfiler_enable_auto_cd= 1
let g:vimfiler_file_icon = "-"
" let g:vimfiler_readonly_file_icon = "𐄂"
let g:vimfiler_readonly_file_icon = "x"
let g:vimfiler_tree_closed_icon = "‣"
let g:vimfiler_tree_leaf_icon = " "
let g:vimfiler_tree_opened_icon = "▾"
let g:vimfiler_marked_file_icon = "✓"
"VimFilerKeyMapping{{{
aug VimFilerKeyMapping
au!
autocmd FileType vimfiler call s:vimfiler_local()
function! s:vimfiler_local()
nmap <buffer><CR> <Plug>(vimfiler_edit_file)
" Unite bookmarkのアクションをVimFilerに
call unite#custom_default_action('source/bookmark/directory' , 'vimfiler')
endfunction
aug END
"}}}
" VimFilerExplorerを自動起動
" gitの場合はgit_rootかつ、バッファの有無でフォーカス変える
function! VimFilerExplorerGit()
let cmd = bufname("%") != "" ? "2wincmd w" : ""
if(system('git rev-parse --is-inside-work-tree') == "true\n")
let git_root = system('git rev-parse --show-cdup')
if git_root == "" |let git_root = "."| endif
exe 'VimFilerExplorer ' . substitute( git_root, '\n', "", "g" )
else
VimFilerExplorer .
endif
exe cmd
endfunction
command!
\ VimFilerExplorerGit
\ call VimFilerExplorerGit()
" vimfilerが最後のbufferならばvimを終了
autocmd BufEnter * if (winnr('$') == 1 && &filetype ==# 'vimfiler') | q | endif
if !has('gui_macvim')
" VimFilerExplorer自動起動
autocmd VimEnter * call VimFilerExplorerGit()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment