scriptencoding utf-8 let s:VCOP = SpaceVim#api#import('vim#compatible') let s:FILE = SpaceVim#api#import('file') if get(g:, 'spacevim_filetree_direction', 'right') ==# 'right' let g:NERDTreeWinPos = 'rightbelow' else let g:NERDTreeWinPos = 'left' endif let g:NERDTreeWinSize=get(g:,'NERDTreeWinSize', get(g:, 'spacevim_sidebar_width', 35)) let g:NERDTreeChDirMode=get(g:,'NERDTreeChDirMode',1) let g:NERDTreeShowHidden = get(g:, '_spacevim_filetree_show_hidden_files', 0) let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', get(g:, '_spacevim_filetree_closed_icon', '')) let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', get(g:, '_spacevim_filetree_opened_icon', '')) let g:NERDTreeMinimalUI=1 augroup nerdtree_zvim autocmd! autocmd bufenter * \ if (winnr('$') == 1 && exists('b:NERDTree') \ && b:NERDTree.isTabTree()) \| q \| endif autocmd FileType nerdtree call s:nerdtreeinit() augroup END function! s:nerdtreeinit() abort nnoremap yY :call copy_to_system_clipboard() nnoremap P :call paste_to_file_manager() nnoremap h :call nerdtree_h() nnoremap d :call NERDTreeDeleteNode() nnoremap l :call nerdtree_l() nnoremap :call nerdtree_h() nnoremap :call nerdtree_l() nnoremap N :call NERDTreeAddNode() nnoremap . :call nerdtree_dot() nnoremap :NERDTreeCWD nnoremap :call nerdtree_enter() " nnoremap :silent! exe 'NERDTree' g:NERDTreeFileNode.GetSelected().path.str() nnoremap :call cursor(2, 1) nnoremap :call cursor(line('$'), 1) endfunction function! s:paste_to_file_manager() abort let path = g:NERDTreeFileNode.GetSelected().path.str() if !isdirectory(path) let path = fnamemodify(path, ':p:h') endif let old_wd = getcwd() if old_wd == path call s:VCOP.systemlist(['xclip-pastefile']) else noautocmd exe 'cd' fnameescape(path) call s:VCOP.systemlist(['xclip-pastefile']) noautocmd exe 'cd' fnameescape(old_wd) endif endfunction function! s:copy_to_system_clipboard() abort let filename = g:NERDTreeFileNode.GetSelected().path.str() call s:VCOP.systemlist(['xclip-copyfile', filename]) echo 'Yanked:' . (type(filename) == 3 ? len(filename) : 1 ) . ( isdirectory(filename) ? 'directory' : 'file' ) endfunction function! s:nerdtree_h() abort " let path = g:NERDTreeFileNode.GetSelected().path.str() " if isdirectory(path) " let path = s:FILE.unify_path(path, ':p:h:h') " else " let path = s:FILE.unify_path(path, ':p:h') " endif " exe 'NERDTreeFind ' . path call g:NERDTreeKeyMap.Invoke('p') call g:NERDTreeKeyMap.Invoke('o') endfunction function! s:nerdtree_l() abort let path = g:NERDTreeFileNode.GetSelected().path.str() if isdirectory(path) if matchstr(getline('.'), 'S') ==# g:NERDTreeDirArrowCollapsible normal! gj else call g:NERDTreeKeyMap.Invoke('o') normal! gj endif else call g:NERDTreeKeyMap.Invoke('o') endif endfunction function! s:nerdtree_dot() abort call g:NERDTreeKeyMap.Invoke('I') endfunction function! s:nerdtree_enter() abort let path = g:NERDTreeFileNode.GetSelected().path.str() if isdirectory(path) silent! exe 'NERDTree' g:NERDTreeFileNode.GetSelected().path.str() else call g:NERDTreeKeyMap.Invoke('o') endif endfunction