set nu set autoread set clipboard+=unnamed " 共享剪贴板 set ruler set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set mouse=a syntax on " 打开语法高亮 colorschem gruvbox filetype plugin indent on
" Plugins will be downloaded under the specified directory. call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged') " Declare the list of plugins. Plug 'tpope/vim-sensible' Plug 'junegunn/seoul256.vim' Plug 'scrooloose/nerdtree' Plug 'scrooloose/syntastic' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'valloric/youcompleteme' Plug 'github/copilot.vim' Plug 'rust-lang/rust.vim'
" List ends here. Plugins become visible to Vim after this call. call plug#end() " 文件导航 https://vimawesome.com/plugin/nerdtree-red " NERDtree 键盘映射 nnoremap <leader>n :NERDTreeFocus<CR> nnoremap <C-n> :NERDTree<CR> nnoremap <C-t> :NERDTreeToggle<CR> nnoremap <C-f> :NERDTreeFind<CR> " NERDtree 自动关闭 " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif " Close the tab if NERDTree is the only window remaining in it. autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif " 防止其他缓冲区替代NERDtree " If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | \ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" 语法高亮 https://vimawesome.com/plugin/syntastic " Syntastic 配置 set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%*
let g:syntastic_always_populate_loc_list = 1 let g:syntastic_auto_loc_list = 1 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0
" 底部状态栏 https://vimawesome.com/plugin/vim-airline-superman let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#formatter = 'default' " 自动补全 https://vimawesome.com/plugin/youcompleteme let g:ycm_autoclose_preview_window_after_completion=1 let g:ycm_autoclose_preview_window_after_insertion=1 let g:ycm_confirm_extra_conf=0 set completeopt-=preview autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口 let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全 let g:ycm_enable_diagnostic_signs = 1