[feat] change file explorer from nerdtree to defx

This commit is contained in:
Jay 2020-09-04 17:51:24 +08:00
parent 6364bb0d8c
commit 3b7049704f

90
.vimrc
View File

@ -14,7 +14,6 @@ Plug 'prabirshrestha/asyncomplete-tscompletejob.vim'
Plug 'tomasr/molokai'
Plug 'scrooloose/nerdcommenter'
Plug 'vim-scripts/DrawIt'
Plug 'scrooloose/nerdtree'
Plug 'easymotion/vim-easymotion'
Plug 'mattn/emmet-vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
@ -32,6 +31,13 @@ Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'ctrlpvim/ctrlp.vim'
" defx file explorer
" require python package pynvim
" install `pip3 install --user pynvim`
Plug 'Shougo/defx.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
" LSP
" JS/TS require
" npm install -g typescript typescript-language-server
@ -109,17 +115,83 @@ nmap <leader>swd <c-w>l
nmap <leader>aa gT
nmap <leader>dd gt
" nerdtree key map
nmap <F3> :NERDTreeToggle<CR>
nmap <leader>me :NERDTreeToggle<CR>
" show hidden file
let NERDTreeShowHidden=1
" delete auto remove buffer
let NERDTreeAutoDeleteBuffer=1
" defx settings
call defx#custom#option('_', {
\ 'winwidth': 40,
\ 'split': 'vertical',
\ 'direction': 'topleft',
\ 'buffer_name': '',
\ 'toggle': 1,
\ 'resume': 1
\ })
nmap <F3> :Defx<CR>
nmap <leader>me :Defx<CR>
autocmd FileType defx call s:defx_my_settings()
function! s:defx_my_settings() abort
" Define mappings
nnoremap <silent><buffer><expr> <CR>
\ defx#is_directory() ?
\ defx#do_action('open_tree', 'toggle') :
\ defx#do_action('drop')
nnoremap <silent><buffer><expr> T
\ defx#do_action('open', 'tabe')
nnoremap <silent><buffer><expr> s
\ defx#do_action('drop', 'vsplit')
nnoremap <silent><buffer><expr> mc
\ defx#do_action('copy')
nnoremap <silent><buffer><expr> mm
\ defx#do_action('move')
nnoremap <silent><buffer><expr> mp
\ defx#do_action('paste')
nnoremap <silent><buffer><expr> P
\ defx#do_action('preview')
nnoremap <silent><buffer><expr> o
\ defx#do_action('open_tree', 'toggle')
nnoremap <silent><buffer><expr> ma
\ defx#do_action('new_file')
nnoremap <silent><buffer><expr> C
\ defx#do_action('toggle_columns',
\ 'mark:indent:icon:filename:type:size:time')
nnoremap <silent><buffer><expr> S
\ defx#do_action('toggle_sort', 'time')
nnoremap <silent><buffer><expr> md
\ defx#do_action('remove')
nnoremap <silent><buffer><expr> mr
\ defx#do_action('rename')
nnoremap <silent><buffer><expr> !
\ defx#do_action('execute_command')
nnoremap <silent><buffer><expr> x
\ defx#do_action('execute_system')
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('repeat')
nnoremap <silent><buffer><expr> h
\ defx#do_action('cd', ['..'])
nnoremap <silent><buffer><expr> ~
\ defx#do_action('cd')
nnoremap <silent><buffer><expr> q
\ defx#do_action('quit')
nnoremap <silent><buffer><expr> <Space>
\ defx#do_action('toggle_select') . 'j'
nnoremap <silent><buffer><expr> *
\ defx#do_action('toggle_select_all')
nnoremap <silent><buffer><expr> j
\ line('.') == line('$') ? 'gg' : 'j'
nnoremap <silent><buffer><expr> k
\ line('.') == 1 ? 'G' : 'k'
nnoremap <silent><buffer><expr> 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')
endfunction
" tagbar
nmap <F8> :TagbarToggle<CR>
nmap <F9> :%!python -m json.tool<CR>
" NeoComplete
let g:neocomplete#enable_at_startup = 1