" Netrw - Vim's built-in file browser. " Put errors in `:messages` let g:netrw_use_errorwindow = 0 " 'o' to (o)pen autocmd FileType netrw map o " Dirvish file browser. " Use relative paths if there is no `conceal` ability. let g:dirvish_relative_paths = (v:version <= 703 ? 1 : 0) augroup dirvishCustomisation autocmd! " Allow fugitive.vim commands in dirvish buffers. autocmd FileType dirvish call fugitive#detect(@%) " Add/Adjust mappings. " - 'o' to (o)pen and 'i' to spl(i)t. " - Create, Delete, Rename with 'mc', 'md', 'mr'. autocmd FileType dirvish let s:nowait = (v:version > 703 ? '' : '') \| execute 'nnoremap '.s:nowait.' o :.call dirvish#open("edit", 0)' \| execute 'nnoremap '.s:nowait.' i :.call dirvish#open("split", 1)' \| execute 'xnoremap '.s:nowait.' O :call dirvish#open("edit", 0)' \| execute 'xnoremap '.s:nowait.' I :call dirvish#open("split", 1)' \| execute 'nnoremap '.s:nowait.' mc :.call FileCreate()' \| execute 'nnoremap '.s:nowait.' md :.call FileDelete()' \| execute 'nnoremap '.s:nowait.' mr :.call FileRename()' augroup END " Create files/directories in dirvish buffers. function! FileCreate() if &ft != "dirvish" | return | endif let filename = inputdialog('New File: ', expand('%'), 0) if filename == "0" | return | endif " Create any directories required. let dirname = fnamemodify(filename, ':p:h') if dirname != expand('%:h') | call system('mkdir -p '.dirname) | endif " Edit the file if it is a file. if !isdirectory(filename) execute 'edit' filename else normal R endif endfunction " Delete files/directories in dirvish buffers. function! FileDelete() if &ft != "dirvish" | return | endif let current = getline('.') let delcheck = confirm('Delete `'.current.'`?', "&Yes\n&No", 2) if delcheck != 1 | return | endif let delcheck = confirm('Are you SURE?', "&Yes\n&No", 2) if delcheck != 1 | return | endif call delete(current, 'rf') | normal R endfunction " Rename files/directories in dirvish buffers. function! FileRename() if &ft != "dirvish" | return | endif let current = getline('.') let newname = inputdialog('Rename: ', current, 0) if newname == "0" | return | endif call rename(current, newname) | normal R endfunction " Fuzzy Finder " Set `p` to FZF if possible. CtrlP is always available at `` if executable('fzf') map p :FZF else let g:ctrlp_map = 'p' endif " CtrlP uses `git ls-files` in git repos, otherwise `ag` then `find`. let g:ctrlp_user_command = [ \ '.git', \ 'cd %s && git ls-files . -co --exclude-standard', \ executable('ag') ? 'ag %s -l --nocolor -g ""' : 'find %s -type f' \] " CtrlP Funky plugin - jump to function definitions in the current file. let g:ctrlp_extensions = ['funky'] map f :CtrlPFunky