Skip to content

Instantly share code, notes, and snippets.

@vlasenkov
Created October 7, 2017 14:21
Show Gist options
  • Save vlasenkov/276eaec6804ee441a95832febc5a3df6 to your computer and use it in GitHub Desktop.
Save vlasenkov/276eaec6804ee441a95832febc5a3df6 to your computer and use it in GitHub Desktop.
Basic Python .vimrc
set encoding=utf-8
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'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'LucHermitte/lh-vim-lib'
Plugin 'davidhalter/jedi-vim'
Plugin 'qpkorr/vim-bufkill'
Plugin 'NLKNguyen/papercolor-theme'
" Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
syntax on
" jedi-vim
autocmd FileType python setlocal completeopt-=preview
let g:jedi#popup_on_dot = 0
let g:jedi#show_call_signatures = 0
if has("gui_running")
set background=light
colorscheme PaperColor
let g:airline_theme='papercolor'
let g:airline#extensions#tabline#enabled = 0
let g:airline#extensions#tabline#buffer_min_count = 0
let g:airline#extensions#tabline#buffer_nr_show = 0
set guioptions-=r
set guioptions-=L
set guifont=Menlo:h13
set cursorline
endif
set hidden
set incsearch
set hlsearch
set wildmenu
set wildmode=longest,list
set wildignore+=*.a,*.o,*.so,*.pyc
set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png
set wildignore+=.DS_Store,.git
set wildignore+=*~,*.swp
set nu
set cc=80
au BufNewFile,BufRead *.py set tabstop=4 softtabstop=4 shiftwidth=4 textwidth=79 tw=0 fo-=t expandtab autoindent fileformat=unix
" Indent Python in the Google way.
setlocal indentexpr=GetGooglePythonIndent(v:lnum)
let s:maxoff = 50 " maximum number of lines to look backwards.
function GetGooglePythonIndent(lnum)
" Indent inside parens.
" Align with the open paren unless it is at the end of the line.
" E.g.
" open_paren_not_at_EOL(100,
" (200,
" 300),
" 400)
" open_paren_at_EOL(
" 100, 200, 300, 400)
call cursor(a:lnum, 1)
let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
\ . " =~ '\\(Comment\\|String\\)$'")
if par_line > 0
call cursor(par_line, 1)
if par_col != col("$") - 1
return par_col
endif
endif
" Delegate the rest to the original function.
return GetPythonIndent(a:lnum)
endfunction
let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment