1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:30:05 +08:00

fix Vimfiler defx support (#2691)

* Fix SPC j d

* Fix windisk for defx

* Add s t key binding for defx

* remove key binding

* Fix wiki
This commit is contained in:
Wang Shidong 2019-03-23 21:22:13 +08:00 committed by GitHub
parent c3c41ca0f0
commit 5e8a168add
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 10 deletions

View File

@ -98,8 +98,17 @@ function! SpaceVim#layers#core#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['j', '$'], 'm`g_', 'push mark and goto end of line', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'b'], '<C-o>', 'jump backward', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'f'], '<C-i>', 'jump forward', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'VimFiler -no-split', 'Explore current directory', 1)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'VimFiler', 'Explore current directory (other window)', 1)
" file tree key bindings
if g:spacevim_filemanager ==# 'vimfiler'
call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'VimFiler -no-split', 'Explore current directory', 1)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'VimFiler', 'Explore current directory (other window)', 1)
elseif g:spacevim_filemanager ==# 'nerdtree'
elseif g:spacevim_filemanager ==# 'defx'
call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'let g:_spacevim_autoclose_defx = 0 | Defx -split=no | let g:_spacevim_autoclose_defx = 1', 'Explore current directory', 1)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'Defx', 'Explore current directory (other window)', 1)
endif
call SpaceVim#mapping#space#def('nmap', ['j', 'j'], '<Plug>(easymotion-overwin-f)', 'jump to a character', 0)
call SpaceVim#mapping#space#def('nmap', ['j', 'J'], '<Plug>(easymotion-overwin-f2)', 'jump to a suite of two characters', 0)
call SpaceVim#mapping#space#def('nnoremap', ['j', 'k'], 'j==', 'go to next line and indent', 0)
@ -174,9 +183,11 @@ function! SpaceVim#layers#core#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['f', '/'], 'call SpaceVim#plugins#find#open()', 'find-files', 1)
if s:SYS.isWindows
call SpaceVim#mapping#space#def('nnoremap', ['f', 'd'], 'call call('
\ . string(s:_function('s:ToggleWinDiskManager')) . ', [])',
\ 'toggle Windows disk manager', 1)
\ . string(s:_function('s:ToggleWinDiskManager')) . ', [])',
\ 'toggle Windows disk manager', 1)
endif
" file tree key bindings
if g:spacevim_filemanager ==# 'vimfiler'
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'VimFiler | doautocmd WinEnter', 'toggle_file_tree', 1)
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'VimFiler -no-toggle | doautocmd WinEnter', 'show_file_tree', 1)

View File

@ -35,7 +35,12 @@ endf
function! s:open_disk(d) abort
call s:close_disk_buffer()
exe 'VimFiler -no-toggle ' . a:d
if g:spacevim_filemanager ==# 'vimfiler'
exe 'VimFiler -no-toggle ' . a:d
elseif g:spacevim_filemanager ==# 'nerdtree'
elseif g:spacevim_filemanager ==# 'defx'
exe 'Defx -no-toggle ' . a:d
endif
doautocmd WinEnter
endfunction

View File

@ -36,12 +36,14 @@ call defx#custom#column('filename', {
\ 'opened_icon': '',
\ })
let g:_spacevim_autoclose_defx = 1
augroup vfinit
au!
autocmd FileType defx call s:defx_init()
" auto close last defx windows
autocmd BufEnter * nested if
\ (!has('vim_starting') && winnr('$') == 1
\ (!has('vim_starting') && winnr('$') == 1 && g:_spacevim_autoclose_defx
\ && &filetype ==# 'defx') |
\ call s:close_last_vimfiler_windows() | endif
augroup END
@ -109,6 +111,8 @@ function! s:defx_init()
\ defx#do_action('drop', 'vsplit')
nnoremap <silent><buffer><expr> sv
\ defx#do_action('drop', 'split')
nnoremap <silent><buffer><expr> st
\ defx#do_action('drop', 'tabedit')
nnoremap <silent><buffer><expr> p
\ defx#do_action('open', 'pedit')
nnoremap <silent><buffer><expr> N

View File

@ -92,9 +92,6 @@ function! s:vimfilerinit()
silent! nunmap <buffer> -
silent! nunmap <buffer> s
nnoremap <silent><buffer> gr :<C-u>Denite grep:<C-R>=<SID>selected()<CR> -buffer-name=grep<CR>
nnoremap <silent><buffer> gf :<C-u>Denite file_rec:<C-R>=<SID>selected()<CR><CR>
nnoremap <silent><buffer> gd :<C-u>call <SID>change_vim_current_dir()<CR>
nnoremap <silent><buffer> sg :<C-u>call <SID>vimfiler_vsplit()<CR>
nnoremap <silent><buffer> sv :<C-u>call <SID>vimfiler_split()<CR>
nnoremap <silent><buffer><expr> st vimfiler#do_action('tabswitch')

View File

@ -85,4 +85,4 @@ The next release is v1.1.0:
SpaceVim releases v1.0.0 at 2018-12-26, please check the release page:
- [SpaceVim releases v0.9.0](https://spacevim.org/SpaceVim-release-v1.0.0/) for all the details
- [SpaceVim releases v1.0.0](https://spacevim.org/SpaceVim-release-v1.0.0/) for all the details