mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:40: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
|
let g:spacevim_simple_mode = 0
|
||||||
""
|
""
|
||||||
" 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
|
||||||
let g:spacevim_filemanager = 'vimfiler'
|
let g:spacevim_filemanager = 'vimfiler'
|
||||||
|
|
||||||
let g:spacevim_sidebar_direction = ''
|
let g:spacevim_sidebar_direction = ''
|
||||||
@ -685,6 +686,7 @@ let g:spacevim_smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default']
|
|||||||
let g:spacevim_smartcloseignoreft = [
|
let g:spacevim_smartcloseignoreft = [
|
||||||
\ 'tagbar',
|
\ 'tagbar',
|
||||||
\ 'vimfiler',
|
\ 'vimfiler',
|
||||||
|
\ 'defx',
|
||||||
\ 'SpaceVimRunner',
|
\ 'SpaceVimRunner',
|
||||||
\ 'SpaceVimREPL',
|
\ 'SpaceVimREPL',
|
||||||
\ 'SpaceVimQuickFix',
|
\ 'SpaceVimQuickFix',
|
||||||
@ -963,6 +965,9 @@ function! SpaceVim#welcome() abort
|
|||||||
if exists(':VimFiler') == 2
|
if exists(':VimFiler') == 2
|
||||||
VimFiler
|
VimFiler
|
||||||
wincmd p
|
wincmd p
|
||||||
|
elseif exists(':Defx') == 2
|
||||||
|
Defx
|
||||||
|
wincmd p
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
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/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/unite.vim',{ 'merged' : 0 , 'loadconf' : 1}])
|
||||||
call add(plugins, ['Shougo/vimproc.vim', {'build' : [(executable('gmake') ? 'gmake' : 'make')]}])
|
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
|
endif
|
||||||
|
|
||||||
if !g:spacevim_vimcompatible
|
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', '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', ['f', 'o'], 'NERDTreeFind', 'open_file_tree', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'NERDTree %', 'show_file_tree_at_buffer_dir', 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
|
endif
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'y'], 'call zvim#util#CopyToClipboard()', 'show-and-copy-buffer-filename', 1)
|
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)'}
|
let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'}
|
||||||
|
@ -351,6 +351,9 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
|||||||
\ . '%#SpaceVim_statusline_b#'
|
\ . '%#SpaceVim_statusline_b#'
|
||||||
\ . ' vimfiler %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
\ . ' vimfiler %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
||||||
\ . s:lsep
|
\ . 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'
|
elseif &filetype ==# 'gista-list'
|
||||||
return '%#SpaceVim_statusline_ia#'
|
return '%#SpaceVim_statusline_ia#'
|
||||||
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
||||||
|
@ -114,4 +114,4 @@ function! s:search_line(path, term) abort "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
" vim:set et sw=2:
|
" vim:set et sw=2 cc=80 nowrap:
|
||||||
|
@ -206,8 +206,10 @@ function! zvim#plug#enable_plug() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zvim#plug#loadPluginBefore(plugin) abort
|
function! zvim#plug#loadPluginBefore(plugin) abort
|
||||||
if matchend(a:plugin, '.vim') == len(a:plugin)
|
if matchend(a:plugin, "\\.vim") == len(a:plugin)
|
||||||
call zvim#util#source_rc('plugins_before/' . 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
|
else
|
||||||
call zvim#util#source_rc('plugins_before/' . a:plugin . '.vim')
|
call zvim#util#source_rc('plugins_before/' . a:plugin . '.vim')
|
||||||
endif
|
endif
|
||||||
|
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*
|
*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*
|
*g:spacevim_plugin_manager_processes*
|
||||||
Set the max process of SpaceVim plugin manager
|
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.
|
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.
|
You can install remark via [npm](https://www.npmjs.com/get-npm), the commands are shown as below.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm -g install remark
|
npm -g install remark
|
||||||
npm -g install remark-cli
|
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:
|
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`
|
1. Via `yarn`
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
yarn global add prettier
|
yarn global add prettier
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Via `npm`
|
2. Via `npm`
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install --global prettier
|
npm install --global prettier
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user