vim+python
#!/bin/bash # install fisa vim config echo '===============================' echo 'start to install dependences...' case "$OSTYPE" in darwin*) brew install vim git pip curl;; linux*) sudo apt-get install vim exuberant-ctags git curl;; *) echo "unknown: OS: $OSTYPE, U should install dependences by yourself" ;; esac sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort echo '===============================' echo 'start to download vimrc file...' cp ~/.vimrc /tmp/vimrc.bak curl -O https://raw.githubusercontent.com/fisadev/fisa-vim-config/master/.vimrc mv .vimrc ~/.vimrc echo '===============================' echo 'start to install vim plugins...' vim +BundleClean +BundleInstall! +qa sudo chown $USER ~/.vim/ echo 'down! enjoy it!'
vim.sh
执行上述脚本
获得.vimrc文件
" Fisa-vim-config " http://fisadev.github.io/fisa-vim-config/ " version: 8.3.1 " ============================================================================ " Vim-plug initialization " Avoid modify this section, unless you are very sure of what you are doing let vim_plug_just_installed = 0 let vim_plug_path = expand('~/.vim/autoload/plug.vim') if !filereadable(vim_plug_path) echo "Installing Vim-plug..." echo "" silent !mkdir -p ~/.vim/autoload silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim let vim_plug_just_installed = 1 endif " manually load vim-plug the first time if vim_plug_just_installed :execute 'source '.fnameescape(vim_plug_path) endif " Obscure hacks done, you can now modify the rest of the .vimrc as you wish :) " ============================================================================ " Active plugins " You can disable or add new ones here: " this needs to be here, so vim-plug knows we are declaring the plugins we " want to use call plug#begin('~/.vim/plugged') " Plugins from github repos: " Override configs by directory Plug 'arielrossanigo/dir-configs-override.vim' " Better file browser Plug 'scrooloose/nerdtree' " Code commenter Plug 'scrooloose/nerdcommenter' " Class/module browser Plug 'majutsushi/tagbar' " Code and files fuzzy finder Plug 'ctrlpvim/ctrlp.vim' " Extension to ctrlp, for fuzzy command finder Plug 'fisadev/vim-ctrlp-cmdpalette' " Zen coding Plug 'mattn/emmet-vim' " Git integration Plug 'motemen/git-vim' " Tab list panel Plug 'kien/tabman.vim' " Airline Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' " Terminal Vim with 256 colors colorscheme Plug 'fisadev/fisa-vim-colorscheme' " Consoles as buffers Plug 'rosenfeld/conque-term' " Pending tasks list Plug 'fisadev/FixedTaskList.vim' " Surround Plug 'tpope/vim-surround' " Autoclose Plug 'Townk/vim-autoclose' " Indent text object Plug 'michaeljsmith/vim-indent-object' " Indentation based movements Plug 'jeetsukumaran/vim-indentwise' " Python autocompletion, go to definition. Plug 'davidhalter/jedi-vim' " Better autocompletion Plug 'Shougo/neocomplcache.vim' " Snippets manager (SnipMate), dependencies, and snippets repo Plug 'MarcWeber/vim-addon-mw-utils' Plug 'tomtom/tlib_vim' Plug 'honza/vim-snippets' Plug 'garbas/vim-snipmate' " Git/mercurial/others diff icons on the side of the file lines Plug 'mhinz/vim-signify' " Automatically sort python imports Plug 'fisadev/vim-isort' " Drag visual blocks arround Plug 'fisadev/dragvisuals.vim' " Window chooser Plug 't9md/vim-choosewin' " Python and other languages code checker Plug 'scrooloose/syntastic' " Paint css colors with the real color Plug 'lilydjwg/colorizer' " Ack code search (requires ack installed in the system) Plug 'mileszs/ack.vim' if has('python') " YAPF formatter for Python Plug 'pignacio/vim-yapf-format' endif " Relative numbering of lines (0 is the current line) " (disabled by default because is very intrusive and can't be easily toggled " on/off. When the plugin is present, will always activate the relative " numbering every time you go to normal mode. Author refuses to add a setting " to avoid that) " Plug 'myusuf3/numbers.vim' " Plugins from vim-scripts repos: " Search results counter Plug 'vim-scripts/IndexedSearch' " XML/HTML tags navigation Plug 'vim-scripts/matchit.zip' " Gvim colorscheme Plug 'vim-scripts/Wombat' " Yank history navigation Plug 'vim-scripts/YankRing.vim' " Tell vim-plug we finished declaring plugins, so it can load them call plug#end() " ============================================================================ " Install plugins the first time vim runs if vim_plug_just_installed echo "Installing Bundles, please ignore key map error messages" :PlugInstall endif " ============================================================================ " Vim settings and mappings " You can edit them as you wish " no vi-compatible set nocompatible " allow plugins by file type (required for plugins!) filetype plugin on filetype indent on " tabs and spaces handling set expandtab set tabstop=4 set softtabstop=4 set shiftwidth=4 " tab length exceptions on some file types autocmd FileType html setlocal shiftwidth=4 tabstop=4 softtabstop=4 autocmd FileType htmldjango setlocal shiftwidth=4 tabstop=4 softtabstop=4 autocmd FileType javascript setlocal shiftwidth=4 tabstop=4 softtabstop=4 " always show status bar set ls=2 " incremental search set incsearch " highlighted search results set hlsearch " syntax highlight on syntax on " show line numbers set nu " tab navigation mappings map tn :tabn<CR> map tp :tabp<CR> map tm :tabm map tt :tabnew map ts :tab split<CR> map <C-S-Right> :tabn<CR> imap <C-S-Right> <ESC>:tabn<CR> map <C-S-Left> :tabp<CR> imap <C-S-Left> <ESC>:tabp<CR> " navigate windows with meta+arrows map <M-Right> <c-w>l map <M-Left> <c-w>h map <M-Up> <c-w>k map <M-Down> <c-w>j imap <M-Right> <ESC><c-w>l imap <M-Left> <ESC><c-w>h imap <M-Up> <ESC><c-w>k imap <M-Down> <ESC><c-w>j " old autocomplete keyboard shortcut imap <C-J> <C-X><C-O> " Comment this line to enable autocompletion preview window " (displays documentation related to the selected completion option) " Disabled by default because preview makes the window flicker set completeopt-=preview " save as sudo ca w!! w !sudo tee "%" " simple recursive grep nmap ,r :Ack nmap ,wr :Ack <cword><CR> " use 256 colors when possible if (&term =~? 'mlterm\|xterm\|xterm-256\|screen-256') || has('nvim') let &t_Co = 256 colorscheme fisa else colorscheme delek endif " colors for gvim if has('gui_running') colorscheme wombat endif " when scrolling, keep cursor 3 lines away from screen border set scrolloff=3 " autocompletion of files and commands behaves like shell " (complete only the common part, list the options that match) set wildmode=list:longest " better backup, swap and undos storage set directory=~/.vim/dirs/tmp " directory to place swap files in set backup " make backup files set backupdir=~/.vim/dirs/backups " where to put backup files set undofile " persistent undos - undo after you re-open the file set undodir=~/.vim/dirs/undos set viminfo+=n~/.vim/dirs/viminfo " store yankring history file there too let g:yankring_history_dir = '~/.vim/dirs/' " create needed directories if they don't exist if !isdirectory(&backupdir) call mkdir(&backupdir, "p") endif if !isdirectory(&directory) call mkdir(&directory, "p") endif if !isdirectory(&undodir) call mkdir(&undodir, "p") endif " ============================================================================ " Plugins settings and mappings " Edit them as you wish. " Tagbar ----------------------------- " toggle tagbar display map <F4> :TagbarToggle<CR> " autofocus on tagbar open let g:tagbar_autofocus = 1 " NERDTree ----------------------------- " toggle nerdtree display map <F3> :NERDTreeToggle<CR> " open nerdtree with the current file selected nmap ,t :NERDTreeFind<CR> " don;t show these file types let NERDTreeIgnore = ['\.pyc$', '\.pyo$'] " Tasklist ------------------------------ " show pending tasks list map <F2> :TaskList<CR> " CtrlP ------------------------------ " file finder mapping let g:ctrlp_map = ',e' " tags (symbols) in current file finder mapping nmap ,g :CtrlPBufTag<CR> " tags (symbols) in all files finder mapping nmap ,G :CtrlPBufTagAll<CR> " general code finder in all files mapping nmap ,f :CtrlPLine<CR> " recent files finder mapping nmap ,m :CtrlPMRUFiles<CR> " commands finder mapping nmap ,c :CtrlPCmdPalette<CR> " to be able to call CtrlP with default search text function! CtrlPWithSearchText(search_text, ctrlp_command_end) execute ':CtrlP' . a:ctrlp_command_end call feedkeys(a:search_text) endfunction " same as previous mappings, but calling with current word as default text nmap ,wg :call CtrlPWithSearchText(expand('<cword>'), 'BufTag')<CR> nmap ,wG :call CtrlPWithSearchText(expand('<cword>'), 'BufTagAll')<CR> nmap ,wf :call CtrlPWithSearchText(expand('<cword>'), 'Line')<CR> nmap ,we :call CtrlPWithSearchText(expand('<cword>'), '')<CR> nmap ,pe :call CtrlPWithSearchText(expand('<cfile>'), '')<CR> nmap ,wm :call CtrlPWithSearchText(expand('<cword>'), 'MRUFiles')<CR> nmap ,wc :call CtrlPWithSearchText(expand('<cword>'), 'CmdPalette')<CR> " don't change working directory let g:ctrlp_working_path_mode = 0 " ignore these files and folders on file finder let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/](\.git|\.hg|\.svn|node_modules)$', \ 'file': '\.pyc$\|\.pyo$', \ } " Syntastic ------------------------------ " show list of errors and warnings on the current file nmap <leader>e :Errors<CR> " check also when just opened the file let g:syntastic_check_on_open = 1 " don't put icons on the sign column (it hides the vcs status icons of signify) let g:syntastic_enable_signs = 0 " custom icons (enable them if you use a patched font, and enable the previous " setting) "let g:syntastic_error_symbol = '✗' "let g:syntastic_warning_symbol = '⚠' "let g:syntastic_style_error_symbol = '✗' "let g:syntastic_style_warning_symbol = '⚠' " Jedi-vim ------------------------------ " All these mappings work only for python code: " Go to definition let g:jedi#goto_command = ',d' " Find ocurrences let g:jedi#usages_command = ',o' " Find assignments let g:jedi#goto_assignments_command = ',a' " Go to definition in new tab nmap ,D :tab split<CR>:call jedi#goto()<CR> " NeoComplCache ------------------------------ " most of them not documented because I'm not sure how they work " (docs aren't good, had to do a lot of trial and error to make " it play nice) let g:neocomplcache_enable_at_startup = 1 let g:neocomplcache_enable_ignore_case = 1 let g:neocomplcache_enable_smart_case = 1 let g:neocomplcache_enable_auto_select = 1 let g:neocomplcache_enable_fuzzy_completion = 1 let g:neocomplcache_enable_camel_case_completion = 1 let g:neocomplcache_enable_underbar_completion = 1 let g:neocomplcache_fuzzy_completion_start_length = 1 let g:neocomplcache_auto_completion_start_length = 1 let g:neocomplcache_manual_completion_start_length = 1 let g:neocomplcache_min_keyword_length = 1 let g:neocomplcache_min_syntax_length = 1 " complete with workds from any opened file let g:neocomplcache_same_filetype_lists = {} let g:neocomplcache_same_filetype_lists._ = '_' " TabMan ------------------------------ " mappings to toggle display, and to focus on it let g:tabman_toggle = 'tl' let g:tabman_focus = 'tf' " Autoclose ------------------------------ " Fix to let ESC work as espected with Autoclose plugin let g:AutoClosePumvisible = {"ENTER": "\<C-Y>", "ESC": "\<ESC>"} " DragVisuals ------------------------------ " mappings to move blocks in 4 directions vmap <expr> <S-M-LEFT> DVB_Drag('left') vmap <expr> <S-M-RIGHT> DVB_Drag('right') vmap <expr> <S-M-DOWN> DVB_Drag('down') vmap <expr> <S-M-UP> DVB_Drag('up') " mapping to duplicate block vmap <expr> D DVB_Duplicate() " Signify ------------------------------ " this first setting decides in which order try to guess your current vcs " UPDATE it to reflect your preferences, it will speed up opening files let g:signify_vcs_list = [ 'git', 'hg' ] " mappings to jump to changed blocks nmap <leader>sn <plug>(signify-next-hunk) nmap <leader>sp <plug>(signify-prev-hunk) " nicer colors highlight DiffAdd cterm=bold ctermbg=none ctermfg=119 highlight DiffDelete cterm=bold ctermbg=none ctermfg=167 highlight DiffChange cterm=bold ctermbg=none ctermfg=227 highlight SignifySignAdd cterm=bold ctermbg=237 ctermfg=119 highlight SignifySignDelete cterm=bold ctermbg=237 ctermfg=167 highlight SignifySignChange cterm=bold ctermbg=237 ctermfg=227 " Window Chooser ------------------------------ " mapping nmap - <Plug>(choosewin) " show big letters let g:choosewin_overlay_enable = 1 " Airline ------------------------------ let g:airline_powerline_fonts = 0 let g:airline_theme = 'bubblegum' let g:airline#extensions#whitespace#enabled = 0 " to use fancy symbols for airline, uncomment the following lines and use a " patched font (more info on the README.rst) "if !exists('g:airline_symbols') " let g:airline_symbols = {} "endif "let g:airline_left_sep = '⮀' "let g:airline_left_alt_sep = '⮁' "let g:airline_right_sep = '⮂' "let g:airline_right_alt_sep = '⮃' "let g:airline_symbols.branch = '⭠' "let g:airline_symbols.readonly = '⭤' "let g:airline_symbols.linenr = '⭡' colorscheme morning
使用vundle作为插件管理工具
"~/.vimrc
"vim config file
"date 2022-03-31
"Created by shouyuan
"""""""""""""""""""""""""""""""""""
"""=>全局配置<="""
"""""""""""""""""""""""""""""""""""
"关闭vi兼容模式"
set nocompatible
"设置历史记录步数"
set history=1000
"侦测文件类型"
filetype on
"载入文件类型插件"
filetype plugin on
"为特定文件类型载入相关缩进文件"
filetype indent on
"当文件在外部被修改时,自动更新该文件"
set autoread
"激活鼠标的使用"
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"保存全局变量"
set viminfo+=!
"带有如下符号的单词不要被换行分割"
set iskeyword+=_,$,@,%,#,-
"通过使用: commands命令,告诉我们文件的哪一行被改变过"
set report=0
"被分割的窗口间显示空白,便于阅读"
set fillchars=vert:\ ,stl:\ ,stlnc:\
"""""""""""""""""""""""""""""""""
"""=>字体和颜色<="""
"""""""""""""""""""""""""""""""""
"自动开启语法高亮"
syntax enable
"设置字体"
"set guifont=dejaVu\ Sans\ MONO\ 10
set guifont=Courier_New:h10:cANSI
"设置颜色"
"colorscheme desert
"高亮显示当前行"
set cursorline
hi cursorline guibg=#00ff00
hi CursorColumn guibg=#00ff00
"高亮显示普通txt文件(需要txt.vim脚本)"
au BufRead,BufNewFile * setfiletype txt
"""""""""""""""""""""""""""""""
"""=>代码折叠功能<="""
"""""""""""""""""""""""""""""""
"激活折叠功能"
set foldenable
"set nofen(这个是关闭折叠功能)"
"设置按照语法方式折叠(可简写set fdm=XX)"
"有6种折叠方法:
"manual 手工定义折叠"
"indent 更多的缩进表示更高级别的折叠"
"expr 用表达式来定义折叠"
"syntax 用语法高亮来定义折叠"
"diff 对没有更改的文本进行折叠"
"marker 对文中的标志进行折叠"
set foldmethod=manual
"set fdl=0(这个是不选用任何折叠方法)"
"设置折叠区域的宽度"
"如果不为0,则在屏幕左侧显示一个折叠标识列
"分别用“-”和“+”来表示打开和关闭的折叠
set foldcolumn=0
"设置折叠层数为3"
setlocal foldlevel=3
"设置为自动关闭折叠"
set foldclose=all
"用空格键来代替zo和zc快捷键实现开关折叠"
"zo O-pen a fold (打开折叠)
"zc C-lose a fold (关闭折叠)
"zf F-old creation (创建折叠)
"nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
"""""""""""""""""""""""""""""""""""
"""=>文字处理<="""
"""""""""""""""""""""""""""""""""""
"使用空格来替换Tab"
set expandtab
"设置所有的Tab和缩进为4个空格"
set tabstop=4
"设定<<和>>命令移动时的宽度为4"
set shiftwidth=4
"使得按退格键时可以一次删除4个空格"
set softtabstop=4
set smarttab
"缩进,自动缩进(继承前一行的缩进)"
"set autoindent 命令打开自动缩进,是下面配置的缩写
"可使用autoindent命令的简写,即“:set ai”和“:set noai”
"还可以使用“:set ai sw=4”在一个命令中打开缩进并设置缩进级别
set ai
set cindent
"智能缩进"
set si
"自动换行”
set wrap
"设置软宽度"
set sw=4
"行内替换"
set gdefault
""""""""""""""""""""""""""""""""""
"""=>Vim 界面<="""
""""""""""""""""""""""""""""""""""
"增强模式中的命令行自动完成操作"
set wildmenu
"显示标尺"
set ruler
"设置命令行的高度"
set cmdheight=1
"显示行数"
set nu
"不要图形按钮"
set go=
"在执行宏命令时,不进行显示重绘;在宏命令执行完成后,一次性重绘,以便提高性能"
set lz
"使回格键(backspace)正常处理indent, eol, start等"
set backspace=eol,start,indent
"允许空格键和光标键跨越行边界"
set whichwrap+=<,>,h,l
"设置魔术"
set magic
"关闭遇到错误时的声音提示"
"关闭错误信息响铃"
set noerrorbells
"关闭使用可视响铃代替呼叫"
set novisualbell
"高亮显示匹配的括号([{和}])"
set showmatch
"匹配括号高亮的时间(单位是十分之一秒)"
set mat=2
"光标移动到buffer的顶部和底部时保持3行距离"
set scrolloff=3
"搜索逐字符高亮"
set hlsearch
set incsearch
"搜索时不区分大小写"
"还可以使用简写(“:set ic”和“:set noic”)"
set ignorecase
"用浅色高亮显示当前行"
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul
"输入的命令显示出来,看的清楚"
set showcmd
""""""""""""""""""""""""""""""""""""
"""=>编码设置<="""
""""""""""""""""""""""""""""""""""""
"设置编码"
set encoding=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
"设置文件编码"
set fileencodings=utf-8
"设置终端编码"
set termencoding=utf-8
"设置语言编码"
set langmenu=zh_CN.UTF-8
set helplang=cn
"""""""""""""""""""""""""""""
"""=>其他设置<="""
"""""""""""""""""""""""""""""
"开启新行时使用智能自动缩进"
set smartindent
set cin
set showmatch
"在处理未保存或只读文件的时候,弹出确认"
set confirm
"隐藏工具栏"
set guioptions-=T
"隐藏菜单栏"
set guioptions-=m
"置空错误铃声的终端代码"
set vb t_vb=
"显示状态栏(默认值为1,表示无法显示状态栏)"
set laststatus=2
"状态行显示的内容"
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
"粘贴不换行问题的解决方法"
set pastetoggle=<F9>
"设置背景颜色"
set background=dark
"文件类型自动检测,代码智能补全"
set completeopt=longest,preview,menu
"共享剪切板"
set clipboard+=unnamed
"从不备份"
set nobackup
set noswapfile
"自动保存"
set autowrite
"显示中文帮助"
if version >= 603
set helplang=cn
set encoding=utf-8
endif
"设置高亮相关项"
highlight Search ctermbg=black ctermfg=white guifg=white guibg=black
""""""""""""""""""""""""""""""""
"""=>在shell脚本开头自动增加解释器以及作者等版权信息<="""
""""""""""""""""""""""""""""""""
"新建.py,.cc,.sh,.java文件,自动插入文件头"
autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()"
"定义函数SetTitle,自动插入文件头"
func SetTitle()
if expand ("%:e") == 'sh'
call setline(1, "#!/bin/bash")
call setline(2, "#Author:shiqing")
call setline(3, "#Time:".strftime("%F %T"))
call setline(4, "#Name:".expand("%"))
call setline(5, "#Version:Cinnamoroll V1.0")
call setline(6, "#Description:This is a production script.")
endif
endfunc
"使用vundle作为插件管理工具"
filetype plugin indent on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"下面添加插件"
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'
"缩进指示线"
Plugin 'Yggdroot/indentLine'
"自动格式化代码"
Plugin 'tell-k/vim-autopep8'
"括号和引号自动补全"
Plugin 'jiangmiao/auto-pairs'
"实时语法检查"
Plugin 'vim-syntastic/syntastic'
call vundle#end()
"F3打开 q退出
"NERDTree config
map <F3> :NERDTreeToggle<CR>
"close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"设置autopep8插件
let g:autopep8_disable_show_diff=1
"===设置indentLine插件==="
"缩进指示线"
let g:indentLine_char='┆'
let g:indentLine_enabled = 1
"===设置YouCompleteMe插件==="
"默认配置文件路径"
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
"打开vim时不再询问是否加载ycm_extra_conf.py配置"
let g:ycm_confirm_extra_conf=0
set completeopt=longest,menu
"Python解释器路径"
let g:ycm_path_to_python_interpreter='/home/buyizhiyou/miniconda3/envs/py39/bin/python3.9'
"是否开启语义补全"
let g:ycm_seed_identifiers_with_syntax=1
"是否在注释中也开启补全"
let g:ycm_complete_in_comments=1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
"开始补全的字符数"
let g:ycm_min_num_of_chars_for_completion=2
"补全后自动关机预览窗口"
let g:ycm_autoclose_preview_window_after_completion=1
"禁止缓存匹配项,每次都重新生成匹配项"
let g:ycm_cache_omnifunc=0
"字符串中也开启补全"
let g:ycm_complete_in_strings = 1
"离开插入模式后自动关闭预览窗口"
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"设置主题颜色
colorscheme morning
" Set cursor shape and color
if &term =~ "xterm"
" INSERT mode
let &t_SI = "\<Esc>[1 q" . "\<Esc>]12;red\x7"
" REPLACE mode
let &t_SR = "\<Esc>[1 q" . "\<Esc>]12;black\x7"
" NORMAL mode
let &t_EI = "\<Esc>[1 q" . "\<Esc>]12;green\x7"
endif
" 1 -> blinking block 闪烁的方块
" 2 -> solid block 不闪烁的方块
" 3 -> blinking underscore 闪烁的下划线
" 4 -> solid underscore 不闪烁的下划线
" 5 -> blinking vertical bar 闪烁的竖线
" 6 -> solid vertical bar 不闪烁的竖线
桔桔桔桔桔桔桔桔桔桔

浙公网安备 33010602011771号