用~/.vimrc打造一個完整python環境
阿新 • • 發佈:2019-01-05
set nocompatible " required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin) " Split navigations set splitbelow nnoremap <C-J> <C-W><C-J> nnoremap <C-K> <C-W><C-K> nnoremap <C-L> <C-W><C-L> nnoremap <C-H> <C-W><C-H> " Enable folding Plugin 'tmhedberg/SimpylFold' let g:SimpylFold_docstring_preview=1 " PEP8 auto indent hi BadWhitespace guifg=gray guibg=red ctermfg=gray ctermbg=red au BufNewFile,BufRead *.py \ set tabstop=4 | \ set softtabstop=4 | \ set shiftwidth=4 | \ set textwidth=79 | \ set expandtab | \ set autoindent | \ set fileformat=unix au BufNewFile,BufRead *.js, *.html, *.css \ set tabstop=2 | \ set softtabstop=2 | \ set shiftwidth=2 Plugin 'vim-scripts/indentpython.vim' au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/ set encoding=utf-8 Bundle 'Valloric/YouCompleteMe' let g:ycm_autoclose_preview_window_after_completion=1 map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR> "python with virtualenv support "py << EOF "import os "import sys "if 'VIRTUAL_ENV' in os.environ: " project_base_dir = os.environ['VIRTUAL_ENV'] " activate_this = os.path.join(project_base_dir, 'bin/activate_this.py') " execfile(activate_this, dict(__file__=activate_this)) " EOF Plugin 'scrooloose/syntastic' Plugin 'nvie/vim-flake8' let python_highlight_all=1 syntax on Plugin 'jnurmine/Zenburn' Plugin 'scrooloose/nerdtree' Plugin 'jistr/vim-nerdtree-tabs' let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree Plugin 'kien/ctrlp.vim' set nu Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'} set clipboard=unnamed """"""""""""""""""""""""" " Quickly Run """"""""""""""""""""""""" map <F5> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w" if &filetype == 'c' exec "!g++ % -o %<" exec "!time ./%<" elseif &filetype == 'cpp' exec "!g++ % -o %<" exec "!time ./%<" elseif &filetype == 'sh' :!time bash % elseif &filetype == 'python' exec "!time python2.7 %" endif endfunc map lv 0v$ Plugin 'tpope/vim-fugitive' " YouCompleteMe set runtimepath+=~/.vim/bundle/YouCompleteMe let g:ycm_collect_identifiers_from_tags_files = 1 " 開啟 YCM 基於標籤引擎 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 註釋與字串中的內容也用於補全 let g:syntastic_ignore_files=[".*\.py$"] let g:ycm_seed_identifiers_with_syntax = 1 " 語法關鍵字補全 let g:ycm_complete_in_comments = 1 let g:ycm_confirm_extra_conf = 0 let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 對映按鍵, 沒有這個會攔截掉tab, 導致其他外掛的tab不能用. let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>'] let g:ycm_complete_in_comments = 1 " 在註釋輸入中也能補全 let g:ycm_complete_in_strings = 1 " 在字串輸入中也能補全 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 註釋和字串中的文字也會被收入補全 let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' let g:ycm_show_diagnostics_ui = 0 " 禁用語法檢查 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 回車即選中當前項 nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳轉到定義處 "let g:ycm_min_num_of_chars_for_completion=2 " "從第2個鍵入字元就開始羅列匹配項 " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required