mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-12 17:55:41 +08:00
Add disk explorer for windows (#2165)
* Add disk explorer for windows * Update windisk.vim * Fix windows support * add key binding * add functions for manager disk * Use SPC f d only in windows os
This commit is contained in:
parent
f11b6b525e
commit
472b71c085
@ -170,6 +170,9 @@ function! SpaceVim#layers#core#config() abort
|
||||
\ 'delete-current-buffer-file', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'F'], 'normal! gf', 'open-cursor-file', 1)
|
||||
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 SpaceVim#plugins#windisk#open()', 'open-windisk-manager', 1)
|
||||
endif
|
||||
if g:spacevim_filemanager ==# 'vimfiler'
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'VimFiler', 'toggle_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'VimFiler -no-toggle', 'show_file_tree', 1)
|
||||
|
@ -386,7 +386,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
\ . '%#SpaceVim_statusline_b# LayerManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimGitLogPopup'
|
||||
return '%#SpaceVim_statusline_a# Git log popup %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
|
||||
elseif &filetype ==# 'SpaceVimWinDiskManager'
|
||||
return '%#SpaceVim_statusline_a# WinDisk %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimTodoManager'
|
||||
return '%#SpaceVim_statusline_a# TODO manager %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
|
||||
|
46
autoload/SpaceVim/plugins/windisk.vim
Normal file
46
autoload/SpaceVim/plugins/windisk.vim
Normal file
@ -0,0 +1,46 @@
|
||||
"=============================================================================
|
||||
" windisk.vim --- disk manager for windows
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
func! SpaceVim#plugins#windisk#open()
|
||||
let disks = s:get_disks()
|
||||
if !empty(disks)
|
||||
" 1. open plugin buffer
|
||||
noautocmd vsplit __windisk__
|
||||
vertical resize 20
|
||||
let s:disk_buffer_nr = bufnr('%')
|
||||
set ft=SpaceVimWinDiskManager
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber winfixwidth
|
||||
" 2. init buffer option and syntax
|
||||
let lines = disks
|
||||
setlocal modifiable
|
||||
call setline(1, lines)
|
||||
setlocal nomodifiable
|
||||
" 2. updated content
|
||||
" 3. init buffer key bindings
|
||||
nnoremap <buffer><silent> <Cr> :call <SID>open_disk(getline('.'))<cr>
|
||||
else
|
||||
" TODO: print warnning, not sure if it is needed.
|
||||
endif
|
||||
endf
|
||||
|
||||
func! s:get_disks()
|
||||
return map(filter(range(65, 97), "isdirectory(nr2char(v:val) . ':/')"), 'nr2char(v:val) . ":/"')
|
||||
endf
|
||||
|
||||
|
||||
function! s:open_disk(d) abort
|
||||
call s:close_disk_buffer()
|
||||
exe 'VimFiler -no-toggle ' . a:d
|
||||
doautocmd WinEnter
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:close_disk_buffer() abort
|
||||
exe 'bd ' . s:disk_buffer_nr
|
||||
endfunction
|
||||
|
Loading…
x
Reference in New Issue
Block a user