From 3b7049704f5d965a16608e37d7375527e807ecf2 Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 4 Sep 2020 17:51:24 +0800 Subject: [PATCH] [feat] change file explorer from nerdtree to defx --- .vimrc | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 9 deletions(-) diff --git a/.vimrc b/.vimrc index 967bee9..c7ac21f 100644 --- a/.vimrc +++ b/.vimrc @@ -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 swd l nmap aa gT nmap dd gt -" nerdtree key map -nmap :NERDTreeToggle -nmap me :NERDTreeToggle -" 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 :Defx +nmap me :Defx +autocmd FileType defx call s:defx_my_settings() +function! s:defx_my_settings() abort + " Define mappings + nnoremap + \ defx#is_directory() ? + \ defx#do_action('open_tree', 'toggle') : + \ defx#do_action('drop') + nnoremap T + \ defx#do_action('open', 'tabe') + nnoremap s + \ defx#do_action('drop', 'vsplit') + nnoremap mc + \ defx#do_action('copy') + nnoremap mm + \ defx#do_action('move') + nnoremap mp + \ defx#do_action('paste') + nnoremap P + \ defx#do_action('preview') + nnoremap o + \ defx#do_action('open_tree', 'toggle') + nnoremap ma + \ defx#do_action('new_file') + nnoremap C + \ defx#do_action('toggle_columns', + \ 'mark:indent:icon:filename:type:size:time') + nnoremap S + \ defx#do_action('toggle_sort', 'time') + nnoremap md + \ defx#do_action('remove') + nnoremap mr + \ defx#do_action('rename') + nnoremap ! + \ defx#do_action('execute_command') + nnoremap x + \ defx#do_action('execute_system') + nnoremap yy + \ defx#do_action('yank_path') + nnoremap . + \ defx#do_action('toggle_ignored_files') + nnoremap ; + \ defx#do_action('repeat') + nnoremap h + \ defx#do_action('cd', ['..']) + nnoremap ~ + \ defx#do_action('cd') + nnoremap q + \ defx#do_action('quit') + nnoremap + \ defx#do_action('toggle_select') . 'j' + nnoremap * + \ defx#do_action('toggle_select_all') + nnoremap j + \ line('.') == line('$') ? 'gg' : 'j' + nnoremap k + \ line('.') == 1 ? 'G' : 'k' + nnoremap r + \ defx#do_action('redraw') + nnoremap + \ defx#do_action('print') + nnoremap cd + \ defx#do_action('change_vim_cwd') +endfunction " tagbar nmap :TagbarToggle -nmap :%!python -m json.tool " NeoComplete let g:neocomplete#enable_at_startup = 1