1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:50:06 +08:00

Add support for nerdtree

This commit is contained in:
wsdjeg 2017-12-01 16:17:32 +08:00
parent edba8c1eed
commit be6593be24
3 changed files with 79 additions and 52 deletions

View File

@ -73,25 +73,9 @@ function! SpaceVim#layers#tools#config() abort
endif endif
map <Leader>td <Plug>TaskList map <Leader>td <Plug>TaskList
noremap <silent> <F8> :TlistToggle<CR> noremap <silent> <F8> :TlistToggle<CR>
function! OpenOrCloseNERDTree() abort
exec 'normal! A'
endfunction
if g:spacevim_filemanager ==# 'nerdtree' if g:spacevim_filemanager ==# 'nerdtree'
noremap <silent> <F3> :NERDTreeToggle<CR> noremap <silent> <F3> :NERDTreeToggle<CR>
endif 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 <silent><buffer><Space>
\ :call OpenOrCloseNERDTree()<cr>
augroup END
endfunction endfunction
" vim:set et sw=2 cc=80: " vim:set et sw=2 cc=80:

View File

@ -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 <silent><buffer> yY :<C-u>call <SID>copy_to_system_clipboard()<CR>
nnoremap <silent><buffer> P :<C-u>call <SID>paste_to_file_manager()<CR>
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

View File

@ -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): 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 | | Key Binding | Description |
| ----------------------------- | ------------------------------------------------- | | ------------------------------ | ------------------------------------------------- |
| `<F3>` or `SPC f t` | Toggle file explorer | | `<F3>` or `SPC f t` | Toggle file explorer |
| **Within _VimFiler_ buffers** | | | **Within _file tree_ buffers** | |
| `<Left>` or `h` | go to parent node and collapse expanded directory | | `<Left>` or `h` | go to parent node and collapse expanded directory |
| `<Down>` or `j` | select next file or directory | | `<Down>` or `j` | select next file or directory |
| `<Up>` or `k` | select previous file or directory | | `<Up>` or `k` | select previous file or directory |
| `<Right>` or `l` | open selected file or expand directory | | `<Right>` or `l` | open selected file or expand directory |
| `Ctrl`+`j` | Un-map | | `Ctrl`+`j` | Un-map |
| `Ctrl`+`l` | Un-map | | `Ctrl`+`l` | Un-map |
| `E` | Un-map | | `E` | Un-map |
| `.` | toggle visible ignored files | | `N` | Create new file under corsor |
| `sv` | Split edit | | `yy` | Copy file full path to system clipboard |
| `sg` | Vertical split edit | | `yY` | Copy file to system clipboard |
| `p` | Preview | | `P` | Paste file to the position under the cursor |
| `i` | Switch to directory history | | `.` | toggle visible ignored files |
| `v` | Quick look | | `sv` | Split edit |
| `gx` | Execute with vimfiler associated | | `sg` | Vertical split edit |
| `'` | Toggle mark current line | | `p` | Preview |
| `V` | Clear all marks | | `i` | Switch to directory history |
| `Ctrl`+`r` | Redraw | | `v` | Quick look |
| `gx` | Execute with vimfiler associated |
| `'` | Toggle mark current line |
| `V` | Clear all marks |
| `Ctrl`+`r` | Redraw |
##### Open file with file tree. ##### Open file with file tree.
@ -1335,7 +1339,7 @@ Custom sign symbol:
| ------ | ----------- | --------------------------- | | ------ | ----------- | --------------------------- |
| `✖` | Error | `g:spacevim_error_symbol` | | `✖` | Error | `g:spacevim_error_symbol` |
| `➤` | warning | `g:spacevim_warning_symbol` | | `➤` | warning | `g:spacevim_warning_symbol` |
| `🛈` | Info | `g:spacevim_info_symbol` | | `🛈` | Info | `g:spacevim_info_symbol` |
### Managing projects ### Managing projects
@ -1347,7 +1351,6 @@ project manager commands start with `p`:
| ----------- | ----------------------------------------------------- | | ----------- | ----------------------------------------------------- |
| `SPC p '` | open a shell in projects root (with the shell layer) | | `SPC p '` | open a shell in projects root (with the shell layer) |
## EditorConfig ## EditorConfig
SpaceVim has support for [EditorConfig](http://editorconfig.org/), a configuration file to “define and maintain consistent coding styles between different editors and IDEs.” 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. 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. 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) ![server-and-client](https://user-images.githubusercontent.com/13142418/32554968-7164fe9c-c4d6-11e7-95f7-f6a6ea75e05b.gif)
<!-- SpaceVim Achievements start --> <!-- SpaceVim Achievements start -->
## Achievements ## Achievements
### issues ### issues
Achievements | Account | Achievements | Account |
----- | ----- | --------------------------------------------------------------------- | ------------------------------------------- |
[100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman) | [100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman) |
### Stars, forks and watchers ### Stars, forks and watchers
Achievements | Account | Achievements | Account |
----- | ----- | ----------------- | ------------------------------------------------- |
First stargazers | [monkeydterry](https://github.com/monkeydterry) | First stargazers | [monkeydterry](https://github.com/monkeydterry) |
100th stargazers | [iwillalwaysbe](https://github.com/iwillalwaysbe) | 100th stargazers | [iwillalwaysbe](https://github.com/iwillalwaysbe) |
1000th stargazers | [elvin-du](https://github.com/elvin-du) | 1000th stargazers | [elvin-du](https://github.com/elvin-du) |
2000th stargazers | [tobiasgoecke](https://github.com/tobiasgoecke) | 2000th stargazers | [tobiasgoecke](https://github.com/tobiasgoecke) |
3000th stargazers | [WellerQu](https://github.com/WellerQu) | 3000th stargazers | [WellerQu](https://github.com/WellerQu) |
<!-- SpaceVim Achievements end --> <!-- SpaceVim Achievements end -->