diff --git a/autoload/SpaceVim/layers/tools.vim b/autoload/SpaceVim/layers/tools.vim index 15da0ce3a..2bf3aef75 100644 --- a/autoload/SpaceVim/layers/tools.vim +++ b/autoload/SpaceVim/layers/tools.vim @@ -73,25 +73,9 @@ function! SpaceVim#layers#tools#config() abort endif map td TaskList noremap :TlistToggle - function! OpenOrCloseNERDTree() abort - exec 'normal! A' - endfunction if g:spacevim_filemanager ==# 'nerdtree' noremap :NERDTreeToggle endif - let g:NERDTreeWinPos=get(g:,'NERDTreeWinPos','right') - let g:NERDTreeWinSize=get(g:,'NERDTreeWinSize',31) - let g:NERDTreeChDirMode=get(g:,'NERDTreeChDirMode',1) - augroup nerdtree_zvim - autocmd! - autocmd bufenter * - \ if (winnr('$') == 1 && exists('b:NERDTree') - \ && b:NERDTree.isTabTree()) - \| q - \| endif - autocmd FileType nerdtree nnoremap - \ :call OpenOrCloseNERDTree() - augroup END endfunction " vim:set et sw=2 cc=80: diff --git a/config/plugins/nerdtree.vim b/config/plugins/nerdtree.vim new file mode 100644 index 000000000..7b31df73b --- /dev/null +++ b/config/plugins/nerdtree.vim @@ -0,0 +1,41 @@ +let s:VCOP = SpaceVim#api#import('vim#compatible') + +let g:NERDTreeWinPos=get(g:,'NERDTreeWinPos','right') +let g:NERDTreeWinSize=get(g:,'NERDTreeWinSize',31) +let g:NERDTreeChDirMode=get(g:,'NERDTreeChDirMode',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() +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 diff --git a/docs/documentation.md b/docs/documentation.md index efb8b863f..88cd59b14 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -881,27 +881,31 @@ VCS integration is supported, there will be a column status, this feature maybe Navigation is centered on the `hjkl` keys with the hope of providing a fast navigation experience like in [vifm](https://github.com/vifm): -| Key Binding | Description | -| ----------------------------- | ------------------------------------------------- | -| `` or `SPC f t` | Toggle file explorer | -| **Within _VimFiler_ buffers** | | -| `` or `h` | go to parent node and collapse expanded directory | -| `` or `j` | select next file or directory | -| `` or `k` | select previous file or directory | -| `` or `l` | open selected file or expand directory | -| `Ctrl`+`j` | Un-map | -| `Ctrl`+`l` | Un-map | -| `E` | Un-map | -| `.` | toggle visible ignored files | -| `sv` | Split edit | -| `sg` | Vertical split edit | -| `p` | Preview | -| `i` | Switch to directory history | -| `v` | Quick look | -| `gx` | Execute with vimfiler associated | -| `'` | Toggle mark current line | -| `V` | Clear all marks | -| `Ctrl`+`r` | Redraw | +| Key Binding | Description | +| ------------------------------ | ------------------------------------------------- | +| `` or `SPC f t` | Toggle file explorer | +| **Within _file tree_ buffers** | | +| `` or `h` | go to parent node and collapse expanded directory | +| `` or `j` | select next file or directory | +| `` or `k` | select previous file or directory | +| `` or `l` | open selected file or expand directory | +| `Ctrl`+`j` | Un-map | +| `Ctrl`+`l` | Un-map | +| `E` | Un-map | +| `N` | Create new file under corsor | +| `yy` | Copy file full path to system clipboard | +| `yY` | Copy file to system clipboard | +| `P` | Paste file to the position under the cursor | +| `.` | toggle visible ignored files | +| `sv` | Split edit | +| `sg` | Vertical split edit | +| `p` | Preview | +| `i` | Switch to directory history | +| `v` | Quick look | +| `gx` | Execute with vimfiler associated | +| `'` | Toggle mark current line | +| `V` | Clear all marks | +| `Ctrl`+`r` | Redraw | ##### Open file with file tree. @@ -1335,7 +1339,7 @@ Custom sign symbol: | ------ | ----------- | --------------------------- | | `✖` | Error | `g:spacevim_error_symbol` | | `➤` | warning | `g:spacevim_warning_symbol` | -| `🛈` | Info | `g:spacevim_info_symbol` | +| `🛈` | Info | `g:spacevim_info_symbol` | ### Managing projects @@ -1347,7 +1351,6 @@ project manager commands start with `p`: | ----------- | ----------------------------------------------------- | | `SPC p '` | open a shell in project’s root (with the shell layer) | - ## EditorConfig SpaceVim has support for [EditorConfig](http://editorconfig.org/), a configuration file to “define and maintain consistent coding styles between different editors and IDEs.” @@ -1362,32 +1365,31 @@ SpaceVim starts a server at launch. This server is killed whenever you close you If you are using neovim, you need to install [neovim-remote](https://github.com/mhinz/neovim-remote), then add this to your bashrc. -``` -export PATH=$PATH:$HOME/.SpaceVim/bin -``` + export PATH=$PATH:$HOME/.SpaceVim/bin Use `svc` to open a file in the existing Vim server, or using `nsvc` to open a file in the existing neovim server. ![server-and-client](https://user-images.githubusercontent.com/13142418/32554968-7164fe9c-c4d6-11e7-95f7-f6a6ea75e05b.gif) + ## Achievements ### issues -Achievements | Account ------ | ----- -[100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman) +| Achievements | Account | +| --------------------------------------------------------------------- | ------------------------------------------- | +| [100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman) | ### Stars, forks and watchers -Achievements | Account ------ | ----- -First stargazers | [monkeydterry](https://github.com/monkeydterry) -100th stargazers | [iwillalwaysbe](https://github.com/iwillalwaysbe) -1000th stargazers | [elvin-du](https://github.com/elvin-du) -2000th stargazers | [tobiasgoecke](https://github.com/tobiasgoecke) -3000th stargazers | [WellerQu](https://github.com/WellerQu) +| Achievements | Account | +| ----------------- | ------------------------------------------------- | +| First stargazers | [monkeydterry](https://github.com/monkeydterry) | +| 100th stargazers | [iwillalwaysbe](https://github.com/iwillalwaysbe) | +| 1000th stargazers | [elvin-du](https://github.com/elvin-du) | +| 2000th stargazers | [tobiasgoecke](https://github.com/tobiasgoecke) | +| 3000th stargazers | [WellerQu](https://github.com/WellerQu) |