mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:30:05 +08:00
Add defx support (#2282)
This commit is contained in:
parent
714926260b
commit
7179777ff5
@ -498,6 +498,7 @@ let g:spacevim_colorscheme_default = 'desert'
|
||||
let g:spacevim_simple_mode = 0
|
||||
""
|
||||
" The default file manager of SpaceVim. Default is 'vimfiler'.
|
||||
" you can also use nerdtree or defx
|
||||
let g:spacevim_filemanager = 'vimfiler'
|
||||
|
||||
let g:spacevim_sidebar_direction = ''
|
||||
@ -685,6 +686,7 @@ let g:spacevim_smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default']
|
||||
let g:spacevim_smartcloseignoreft = [
|
||||
\ 'tagbar',
|
||||
\ 'vimfiler',
|
||||
\ 'defx',
|
||||
\ 'SpaceVimRunner',
|
||||
\ 'SpaceVimREPL',
|
||||
\ 'SpaceVimQuickFix',
|
||||
@ -963,6 +965,9 @@ function! SpaceVim#welcome() abort
|
||||
if exists(':VimFiler') == 2
|
||||
VimFiler
|
||||
wincmd p
|
||||
elseif exists(':Defx') == 2
|
||||
Defx
|
||||
wincmd p
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
@ -17,6 +17,8 @@ function! SpaceVim#layers#core#plugins() abort
|
||||
call add(plugins, ['Shougo/vimfiler.vim',{'merged' : 0, 'loadconf' : 1 , 'loadconf_before' : 1, 'on_cmd' : ['VimFiler', 'VimFilerBufferDir']}])
|
||||
call add(plugins, ['Shougo/unite.vim',{ 'merged' : 0 , 'loadconf' : 1}])
|
||||
call add(plugins, ['Shougo/vimproc.vim', {'build' : [(executable('gmake') ? 'gmake' : 'make')]}])
|
||||
elseif g:spacevim_filemanager ==# 'defx'
|
||||
call add(plugins, ['Shougo/defx.nvim',{'merged' : 0, 'loadconf' : 1 , 'loadconf_before' : 1}])
|
||||
endif
|
||||
|
||||
if !g:spacevim_vimcompatible
|
||||
@ -183,6 +185,12 @@ function! SpaceVim#layers#core#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'NERDTree', 'show_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], 'NERDTreeFind', 'open_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'NERDTree %', 'show_file_tree_at_buffer_dir', 1)
|
||||
elseif g:spacevim_filemanager ==# 'defx'
|
||||
" TODO: fix all these command
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'Defx', 'toggle_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'Defx -no-toggle', 'show_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], 'Defx -find', 'open_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'Defx -no-toggle', 'show_file_tree_at_buffer_dir', 1)
|
||||
endif
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'y'], 'call zvim#util#CopyToClipboard()', 'show-and-copy-buffer-filename', 1)
|
||||
let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'}
|
||||
|
@ -351,6 +351,9 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
\ . '%#SpaceVim_statusline_b#'
|
||||
\ . ' vimfiler %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
||||
\ . s:lsep
|
||||
elseif &filetype ==# 'defx'
|
||||
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# defx %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
|
||||
elseif &filetype ==# 'gista-list'
|
||||
return '%#SpaceVim_statusline_ia#'
|
||||
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
||||
|
@ -114,4 +114,4 @@ function! s:search_line(path, term) abort "{{{
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
" vim:set et sw=2:
|
||||
" vim:set et sw=2 cc=80 nowrap:
|
||||
|
@ -1,216 +1,218 @@
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
function! s:install_manager() abort
|
||||
" Fsep && Psep
|
||||
if has('win16') || has('win32') || has('win64')
|
||||
let s:Psep = ';'
|
||||
let s:Fsep = '\'
|
||||
" Fsep && Psep
|
||||
if has('win16') || has('win32') || has('win64')
|
||||
let s:Psep = ';'
|
||||
let s:Fsep = '\'
|
||||
else
|
||||
let s:Psep = ':'
|
||||
let s:Fsep = '/'
|
||||
endif
|
||||
" auto install plugin manager
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
"auto install neobundle
|
||||
if filereadable(expand(g:spacevim_plugin_bundle_dir)
|
||||
\ . 'neobundle.vim'. s:Fsep. 'README.md')
|
||||
let g:_spacevim_neobundle_installed = 1
|
||||
else
|
||||
let s:Psep = ':'
|
||||
let s:Fsep = '/'
|
||||
if executable('git')
|
||||
exec '!git clone '
|
||||
\ .'https://github.com/'
|
||||
\ .'Shougo/neobundle.vim'
|
||||
\ . ' '
|
||||
\ . fnameescape(g:spacevim_plugin_bundle_dir)
|
||||
\ . 'neobundle.vim'
|
||||
let g:_spacevim_neobundle_installed = 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom 'You need install git!'
|
||||
echohl None
|
||||
endif
|
||||
endif
|
||||
" auto install plugin manager
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
"auto install neobundle
|
||||
if filereadable(expand(g:spacevim_plugin_bundle_dir)
|
||||
\ . 'neobundle.vim'. s:Fsep. 'README.md')
|
||||
let g:_spacevim_neobundle_installed = 1
|
||||
else
|
||||
if executable('git')
|
||||
exec '!git clone '
|
||||
\ .'https://github.com/'
|
||||
\ .'Shougo/neobundle.vim'
|
||||
\ . ' '
|
||||
\ . fnameescape(g:spacevim_plugin_bundle_dir)
|
||||
\ . 'neobundle.vim'
|
||||
let g:_spacevim_neobundle_installed = 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom 'You need install git!'
|
||||
echohl None
|
||||
endif
|
||||
endif
|
||||
exec 'set runtimepath+='
|
||||
\ . fnameescape(g:spacevim_plugin_bundle_dir)
|
||||
\ . 'neobundle.vim'
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
"auto install dein
|
||||
if filereadable(expand(g:spacevim_plugin_bundle_dir)
|
||||
\ . join(['repos', 'github.com',
|
||||
\ 'Shougo', 'dein.vim', 'README.md'],
|
||||
\ s:Fsep))
|
||||
let g:_spacevim_dein_installed = 1
|
||||
else
|
||||
if executable('git')
|
||||
exec '!git clone https://github.com/Shougo/dein.vim "'
|
||||
\ . expand(g:spacevim_plugin_bundle_dir)
|
||||
\ . join(['repos', 'github.com',
|
||||
\ 'Shougo', 'dein.vim"'], s:Fsep)
|
||||
let g:_spacevim_dein_installed = 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom 'You need install git!'
|
||||
echohl None
|
||||
endif
|
||||
endif
|
||||
exec 'set runtimepath+='. fnameescape(g:spacevim_plugin_bundle_dir)
|
||||
\ . join(['repos', 'github.com', 'Shougo',
|
||||
\ 'dein.vim'], s:Fsep)
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
"auto install vim-plug
|
||||
if filereadable(expand('~/.cache/vim-plug/autoload/plug.vim'))
|
||||
let g:_spacevim_vim_plug_installed = 1
|
||||
else
|
||||
if executable('curl')
|
||||
exec '!curl -fLo '
|
||||
\ . '~/.cache/vim-plug/autoload/plug.vim'
|
||||
\ . ' --create-dirs '
|
||||
\ . 'https://raw.githubusercontent.com/'
|
||||
\ . 'junegunn/vim-plug/master/plug.vim'
|
||||
let g:_spacevim_vim_plug_installed = 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom 'You need install curl!'
|
||||
echohl None
|
||||
endif
|
||||
endif
|
||||
exec 'set runtimepath+=~/.cache/vim-plug/'
|
||||
exec 'set runtimepath+='
|
||||
\ . fnameescape(g:spacevim_plugin_bundle_dir)
|
||||
\ . 'neobundle.vim'
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
"auto install dein
|
||||
if filereadable(expand(g:spacevim_plugin_bundle_dir)
|
||||
\ . join(['repos', 'github.com',
|
||||
\ 'Shougo', 'dein.vim', 'README.md'],
|
||||
\ s:Fsep))
|
||||
let g:_spacevim_dein_installed = 1
|
||||
else
|
||||
if executable('git')
|
||||
exec '!git clone https://github.com/Shougo/dein.vim "'
|
||||
\ . expand(g:spacevim_plugin_bundle_dir)
|
||||
\ . join(['repos', 'github.com',
|
||||
\ 'Shougo', 'dein.vim"'], s:Fsep)
|
||||
let g:_spacevim_dein_installed = 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom 'You need install git!'
|
||||
echohl None
|
||||
endif
|
||||
endif
|
||||
exec 'set runtimepath+='. fnameescape(g:spacevim_plugin_bundle_dir)
|
||||
\ . join(['repos', 'github.com', 'Shougo',
|
||||
\ 'dein.vim'], s:Fsep)
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
"auto install vim-plug
|
||||
if filereadable(expand('~/.cache/vim-plug/autoload/plug.vim'))
|
||||
let g:_spacevim_vim_plug_installed = 1
|
||||
else
|
||||
if executable('curl')
|
||||
exec '!curl -fLo '
|
||||
\ . '~/.cache/vim-plug/autoload/plug.vim'
|
||||
\ . ' --create-dirs '
|
||||
\ . 'https://raw.githubusercontent.com/'
|
||||
\ . 'junegunn/vim-plug/master/plug.vim'
|
||||
let g:_spacevim_vim_plug_installed = 1
|
||||
else
|
||||
echohl WarningMsg
|
||||
echom 'You need install curl!'
|
||||
echohl None
|
||||
endif
|
||||
endif
|
||||
exec 'set runtimepath+=~/.cache/vim-plug/'
|
||||
endif
|
||||
endf
|
||||
|
||||
if get(g:,'spacevim_enable_plugins', 1)
|
||||
call s:install_manager()
|
||||
call s:install_manager()
|
||||
endif
|
||||
|
||||
function! zvim#plug#begin(path) abort
|
||||
let g:unite_source_menu_menus.AddedPlugins =
|
||||
\ {'description':
|
||||
\ 'All the Added plugins'
|
||||
\ . ' <leader>lp'}
|
||||
let g:unite_source_menu_menus.AddedPlugins.command_candidates = []
|
||||
nnoremap <silent><Leader>lp :Unite -silent
|
||||
\ -winheight=17 -start-insert menu:AddedPlugins<CR>
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
call neobundle#begin(a:path)
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#begin(a:path)
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
call plug#begin(a:path)
|
||||
endif
|
||||
let g:unite_source_menu_menus.AddedPlugins =
|
||||
\ {'description':
|
||||
\ 'All the Added plugins'
|
||||
\ . ' <leader>lp'}
|
||||
let g:unite_source_menu_menus.AddedPlugins.command_candidates = []
|
||||
nnoremap <silent><Leader>lp :Unite -silent
|
||||
\ -winheight=17 -start-insert menu:AddedPlugins<CR>
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
call neobundle#begin(a:path)
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#begin(a:path)
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
call plug#begin(a:path)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zvim#plug#end() abort
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
call neobundle#end()
|
||||
if g:spacevim_checkinstall == 1
|
||||
silent! let g:_spacevim_checking_flag = neobundle#exists_not_installed_bundles()
|
||||
if g:_spacevim_checking_flag
|
||||
augroup SpaceVimCheckInstall
|
||||
au!
|
||||
au VimEnter * SPInstall
|
||||
augroup END
|
||||
endif
|
||||
endif
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#end()
|
||||
if g:spacevim_checkinstall == 1
|
||||
silent! let g:_spacevim_checking_flag = dein#check_install()
|
||||
if g:_spacevim_checking_flag
|
||||
augroup SpaceVimCheckInstall
|
||||
au!
|
||||
au VimEnter * SPInstall
|
||||
augroup END
|
||||
endif
|
||||
endif
|
||||
call dein#call_hook('source')
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
call plug#end()
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
call neobundle#end()
|
||||
if g:spacevim_checkinstall == 1
|
||||
silent! let g:_spacevim_checking_flag = neobundle#exists_not_installed_bundles()
|
||||
if g:_spacevim_checking_flag
|
||||
augroup SpaceVimCheckInstall
|
||||
au!
|
||||
au VimEnter * SPInstall
|
||||
augroup END
|
||||
endif
|
||||
endif
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#end()
|
||||
if g:spacevim_checkinstall == 1
|
||||
silent! let g:_spacevim_checking_flag = dein#check_install()
|
||||
if g:_spacevim_checking_flag
|
||||
augroup SpaceVimCheckInstall
|
||||
au!
|
||||
au VimEnter * SPInstall
|
||||
augroup END
|
||||
endif
|
||||
endif
|
||||
call dein#call_hook('source')
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
call plug#end()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zvim#plug#defind_hooks(bundle) abort
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
let s:hooks = neobundle#get_hooks(a:bundle)
|
||||
func! s:hooks.on_source(bundle) abort
|
||||
call zvim#util#source_rc('plugins/' . split(a:bundle['name'],'\.')[0] . '.vim')
|
||||
endf
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#config(g:dein#name, {
|
||||
\ 'hook_source' : "call zvim#util#source_rc('plugins/" . split(g:dein#name,'\.')[0] . ".vim')"
|
||||
\ })
|
||||
endif
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
let s:hooks = neobundle#get_hooks(a:bundle)
|
||||
func! s:hooks.on_source(bundle) abort
|
||||
call zvim#util#source_rc('plugins/' . split(a:bundle['name'],'\.')[0] . '.vim')
|
||||
endf
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#config(g:dein#name, {
|
||||
\ 'hook_source' : "call zvim#util#source_rc('plugins/" . split(g:dein#name,'\.')[0] . ".vim')"
|
||||
\ })
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zvim#plug#fetch() abort
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
NeoBundleFetch 'Shougo/neobundle.vim'
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#add('Shougo/dein.vim')
|
||||
endif
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
NeoBundleFetch 'Shougo/neobundle.vim'
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
call dein#add('Shougo/dein.vim')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:plugins = []
|
||||
|
||||
fu! s:parser(args) abort
|
||||
return a:args
|
||||
return a:args
|
||||
endf
|
||||
let g:_spacevim_plugins = []
|
||||
function! zvim#plug#add(repo,...) abort
|
||||
let g:spacevim_plugin_name = ''
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
exec 'NeoBundle "'.a:repo.'"'.','.join(a:000,',')
|
||||
let g:spacevim_plugin_name = split(a:repo, '/')[-1]
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
if len(a:000) > 0
|
||||
call dein#add(a:repo,s:parser(a:000[0]))
|
||||
else
|
||||
call dein#add(a:repo)
|
||||
endif
|
||||
let g:spacevim_plugin_name = g:dein#name
|
||||
call add(g:_spacevim_plugins, g:dein#name)
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
if len(a:000) > 0
|
||||
exec "Plug '".a:repo."', ".join(a:000,',')
|
||||
else
|
||||
exec "Plug '".a:repo."'"
|
||||
endif
|
||||
let g:spacevim_plugin_name = split(a:repo, '/')[-1]
|
||||
let g:spacevim_plugin_name = ''
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
exec 'NeoBundle "'.a:repo.'"'.','.join(a:000,',')
|
||||
let g:spacevim_plugin_name = split(a:repo, '/')[-1]
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
if len(a:000) > 0
|
||||
call dein#add(a:repo,s:parser(a:000[0]))
|
||||
else
|
||||
call dein#add(a:repo)
|
||||
endif
|
||||
let str = get(g:,'_spacevim_plugin_layer', 'custom plugin')
|
||||
let str = '[' . str . ']'
|
||||
let str = str . repeat(' ', 25 - len(str))
|
||||
exec 'call add(g:unite_source_menu_menus'
|
||||
\ . '.AddedPlugins.command_candidates, ["'. str . '['
|
||||
\ . a:repo
|
||||
\ . (len(a:000) > 0 ? (']'
|
||||
\ . repeat(' ', 40 - len(a:repo))
|
||||
\ . '[lazy loaded] [' . string(a:000[0])) : '')
|
||||
\ . ']","OpenBrowser https://github.com/'
|
||||
\ . a:repo
|
||||
\ . '"])'
|
||||
call add(s:plugins, a:repo)
|
||||
let g:spacevim_plugin_name = g:dein#name
|
||||
call add(g:_spacevim_plugins, g:dein#name)
|
||||
elseif g:spacevim_plugin_manager ==# 'vim-plug'
|
||||
if len(a:000) > 0
|
||||
exec "Plug '".a:repo."', ".join(a:000,',')
|
||||
else
|
||||
exec "Plug '".a:repo."'"
|
||||
endif
|
||||
let g:spacevim_plugin_name = split(a:repo, '/')[-1]
|
||||
endif
|
||||
let str = get(g:,'_spacevim_plugin_layer', 'custom plugin')
|
||||
let str = '[' . str . ']'
|
||||
let str = str . repeat(' ', 25 - len(str))
|
||||
exec 'call add(g:unite_source_menu_menus'
|
||||
\ . '.AddedPlugins.command_candidates, ["'. str . '['
|
||||
\ . a:repo
|
||||
\ . (len(a:000) > 0 ? (']'
|
||||
\ . repeat(' ', 40 - len(a:repo))
|
||||
\ . '[lazy loaded] [' . string(a:000[0])) : '')
|
||||
\ . ']","OpenBrowser https://github.com/'
|
||||
\ . a:repo
|
||||
\ . '"])'
|
||||
call add(s:plugins, a:repo)
|
||||
endfunction
|
||||
|
||||
function! zvim#plug#tap(plugin) abort
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
return neobundle#tap(a:plugin)
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
return dein#tap(a:plugin)
|
||||
endif
|
||||
if g:spacevim_plugin_manager ==# 'neobundle'
|
||||
return neobundle#tap(a:plugin)
|
||||
elseif g:spacevim_plugin_manager ==# 'dein'
|
||||
return dein#tap(a:plugin)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zvim#plug#enable_plug() abort
|
||||
return g:_spacevim_neobundle_installed
|
||||
\ || g:_spacevim_dein_installed
|
||||
\ || g:_spacevim_vim_plug_installed
|
||||
return g:_spacevim_neobundle_installed
|
||||
\ || g:_spacevim_dein_installed
|
||||
\ || g:_spacevim_vim_plug_installed
|
||||
endfunction
|
||||
|
||||
function! zvim#plug#loadPluginBefore(plugin) abort
|
||||
if matchend(a:plugin, '.vim') == len(a:plugin)
|
||||
call zvim#util#source_rc('plugins_before/' . a:plugin)
|
||||
else
|
||||
call zvim#util#source_rc('plugins_before/' . a:plugin . '.vim')
|
||||
endif
|
||||
if matchend(a:plugin, "\\.vim") == len(a:plugin)
|
||||
call zvim#util#source_rc('plugins_before/' . a:plugin)
|
||||
elseif matchend(a:plugin, "\\.nvim") == len(a:plugin)
|
||||
call zvim#util#source_rc('plugins_before/' . a:plugin[:-6] . '.vim')
|
||||
else
|
||||
call zvim#util#source_rc('plugins_before/' . a:plugin . '.vim')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
145
config/plugins/defx.vim
Normal file
145
config/plugins/defx.vim
Normal file
@ -0,0 +1,145 @@
|
||||
"=============================================================================
|
||||
" defx.vim --- defx config
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
" defx supported is added in https://github.com/SpaceVim/SpaceVim/pull/2282
|
||||
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
call defx#custom#option('_', {
|
||||
\ 'winwidth': g:spacevim_sidebar_width,
|
||||
\ 'split': 'vertical',
|
||||
\ 'direction': 'botright',
|
||||
\ 'show_ignored_files': 0,
|
||||
\ 'buffer_name': '',
|
||||
\ 'toggle': 1,
|
||||
\ 'resume': 1
|
||||
\ })
|
||||
|
||||
call defx#custom#column('mark', {
|
||||
\ 'readonly_icon': '',
|
||||
\ 'selected_icon': '',
|
||||
\ })
|
||||
|
||||
call defx#custom#column('filename', {
|
||||
\ 'directory_icon': '',
|
||||
\ 'opened_icon': '',
|
||||
\ })
|
||||
|
||||
augroup vfinit
|
||||
au!
|
||||
autocmd FileType defx call s:defx_init()
|
||||
" auto close last defx windows
|
||||
" autocmd BufEnter * nested if (!has('vim_starting')
|
||||
" \ && winnr('$') == 1 && &filetype ==# 'vimfiler') |
|
||||
" \ q | endif
|
||||
augroup END
|
||||
|
||||
function! s:defx_init()
|
||||
setl nonumber
|
||||
setl norelativenumber
|
||||
setl listchars=
|
||||
|
||||
silent! nunmap <buffer> <Space>
|
||||
silent! nunmap <buffer> <C-l>
|
||||
silent! nunmap <buffer> <C-j>
|
||||
silent! nunmap <buffer> E
|
||||
silent! nunmap <buffer> gr
|
||||
silent! nunmap <buffer> gf
|
||||
silent! nunmap <buffer> -
|
||||
silent! nunmap <buffer> s
|
||||
|
||||
" nnoremap <silent><buffer><expr> st vimfiler#do_action('tabswitch')
|
||||
" nnoremap <silent><buffer> yY :<C-u>call <SID>copy_to_system_clipboard()<CR>
|
||||
nnoremap <silent><buffer><expr> '
|
||||
\ defx#do_action('toggle_select') . 'j'
|
||||
" TODO: we need an action to clear all selections
|
||||
nnoremap <silent><buffer><expr> V
|
||||
\ defx#do_action('toggle_select_all')
|
||||
" nmap <buffer> v <Plug>(vimfiler_quick_look)
|
||||
" nmap <buffer> p <Plug>(vimfiler_preview_file)
|
||||
" nmap <buffer> i <Plug>(vimfiler_switch_to_history_directory)
|
||||
|
||||
" Define mappings
|
||||
nnoremap <silent><buffer><expr> gx
|
||||
\ defx#do_action('execute_system')
|
||||
nnoremap <silent><buffer><expr> yy
|
||||
\ defx#do_action('copy')
|
||||
nnoremap <silent><buffer><expr> q
|
||||
\ defx#do_action('quit')
|
||||
nnoremap <silent><buffer><expr> m
|
||||
\ defx#do_action('move')
|
||||
nnoremap <silent><buffer><expr> P
|
||||
\ defx#do_action('paste')
|
||||
nnoremap <silent><buffer><expr> h defx#do_action('call', 'DefxSmartH')
|
||||
nnoremap <silent><buffer><expr> <Left> defx#do_action('call', 'DefxSmartH')
|
||||
nnoremap <silent><buffer><expr> l
|
||||
\ defx#is_directory() ?
|
||||
\ defx#do_action('open_tree') . 'j' : defx#do_action('open')
|
||||
nnoremap <silent><buffer><expr> <Right>
|
||||
\ defx#is_directory() ?
|
||||
\ defx#do_action('open_tree') . 'j' : defx#do_action('open')
|
||||
nnoremap <silent><buffer><expr> <Cr>
|
||||
\ defx#is_directory() ?
|
||||
\ defx#do_action('open_directory') : defx#do_action('drop')
|
||||
nnoremap <silent><buffer><expr> <2-LeftMouse>
|
||||
\ defx#is_directory() ?
|
||||
\ defx#do_action('open_tree') : defx#do_action('drop')
|
||||
nnoremap <silent><buffer><expr> sg
|
||||
\ defx#do_action('drop', 'vsplit')
|
||||
nnoremap <silent><buffer><expr> sv
|
||||
\ defx#do_action('drop', 'split')
|
||||
nnoremap <silent><buffer><expr> p
|
||||
\ defx#do_action('open', 'pedit')
|
||||
nnoremap <silent><buffer><expr> N
|
||||
\ defx#do_action('new_file')
|
||||
nnoremap <silent><buffer><expr> d
|
||||
\ defx#do_action('remove')
|
||||
nnoremap <silent><buffer><expr> r
|
||||
\ defx#do_action('rename')
|
||||
nnoremap <silent><buffer><expr> yy
|
||||
\ defx#do_action('yank_path')
|
||||
nnoremap <silent><buffer><expr> .
|
||||
\ defx#do_action('toggle_ignored_files')
|
||||
nnoremap <silent><buffer><expr> ~
|
||||
\ defx#do_action('cd')
|
||||
nnoremap <silent><buffer><expr> j
|
||||
\ line('.') == line('$') ? 'gg' : 'j'
|
||||
nnoremap <silent><buffer><expr> k
|
||||
\ line('.') == 1 ? 'G' : 'k'
|
||||
nnoremap <silent><buffer><expr> <C-r>
|
||||
\ defx#do_action('redraw')
|
||||
nnoremap <silent><buffer><expr> <C-g>
|
||||
\ defx#do_action('print')
|
||||
nnoremap <silent><buffer><expr> cd
|
||||
\ defx#do_action('change_vim_cwd')
|
||||
endf
|
||||
|
||||
function! DefxSmartH(_)
|
||||
" candidate is opend tree?
|
||||
if defx#is_opened_tree()
|
||||
return defx#call_action('close_tree')
|
||||
endif
|
||||
|
||||
" parent is root?
|
||||
let s:candidate = defx#get_candidate()
|
||||
let s:parent = fnamemodify(s:candidate['action__path'], s:candidate['is_directory'] ? ':p:h:h' : ':p:h')
|
||||
let sep = s:SYS.isWindows ? '\\' : '/'
|
||||
if s:trim_right(s:parent, sep) == s:trim_right(b:defx.paths[0], sep)
|
||||
return defx#call_action('cd', ['..'])
|
||||
endif
|
||||
|
||||
" move to parent.
|
||||
call defx#call_action('search', s:parent)
|
||||
|
||||
" if you want close_tree immediately, enable below line.
|
||||
call defx#call_action('close_tree')
|
||||
endfunction
|
||||
|
||||
function! s:trim_right(str, trim)
|
||||
return substitute(a:str, printf('%s$', a:trim), '', 'g')
|
||||
endfunction
|
2
config/plugins_before/defx.vim
Normal file
2
config/plugins_before/defx.vim
Normal file
@ -0,0 +1,2 @@
|
||||
nnoremap <silent> <F3> :Defx<Cr>
|
||||
|
@ -566,7 +566,8 @@ plugins will be installed.
|
||||
<
|
||||
|
||||
*g:spacevim_filemanager*
|
||||
The default file manager of SpaceVim. Default is 'vimfiler'.
|
||||
The default file manager of SpaceVim. Default is 'vimfiler'. you can also use
|
||||
nerdtree or defx
|
||||
|
||||
*g:spacevim_plugin_manager_processes*
|
||||
Set the max process of SpaceVim plugin manager
|
||||
|
@ -33,6 +33,7 @@ To use this configuration layer, update custom configuration file with:
|
||||
SpaceVim uses remark to format Markdown file by default, but we suggest using [Prettier](https://github.com/prettier/prettier) on Windows.
|
||||
|
||||
You can install remark via [npm](https://www.npmjs.com/get-npm), the commands are shown as below.
|
||||
|
||||
```sh
|
||||
npm -g install remark
|
||||
npm -g install remark-cli
|
||||
@ -42,10 +43,13 @@ npm -g install remark-stringify
|
||||
You can install [Prettier](https://github.com/prettier/prettier) via [yarn](https://yarnpkg.com/lang/zh-hans/docs/install/#windows-stable) or [npm](https://www.npmjs.com/get-npm), the commands are shown as below:
|
||||
|
||||
1. Via `yarn`
|
||||
|
||||
```sh
|
||||
yarn global add prettier
|
||||
```
|
||||
|
||||
2. Via `npm`
|
||||
|
||||
```sh
|
||||
npm install --global prettier
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user