Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 75 lines (60 sloc) 2.349 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
let python_highlight_all=1

let b:switch_definitions = [
    \ ["assertEqual", "assertNotEqual"],
    \ ["min", "max"],
\ ]

let s:python = substitute(system('which python || which pypy'), '\n', '', '')
let s:condent = system('which condent')
if !v:shell_error
    let s:condent = substitute(s:condent, '\n', '', '')
    exec 'setlocal equalprg=' . s:python . '\ ' . s:condent
endif

setlocal errorformat=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
setlocal makeprg=python\ %

setlocal matchpairs-=<:>
let b:delimitMate_nesting_quotes = ['"']
let b:delimitMate_expand_cr = 1

nnoremap <buffer> gd :YcmCompleter GoToDeclaration<CR>
nnoremap <buffer> [d :YcmCompleter GoToDefinitionElseDeclaration<CR>

function! Reindent(delimiter)
    execute "normal! va" . a:delimiter . "o"
    normal! ?\i*
    normal! o
    normal! =
    normal! ']
endfunction

" Make inserting closing delimiters automatically reindent the container and
" move to the end again
" inoremap <buffer> } }<C-G>u<C-O>:call Reindent('}')<CR><Right>
" inoremap <buffer> ] ]<C-G>u<C-O>:call Reindent(']')<CR><Right>
" inoremap <buffer> ) )<C-G>u<C-O>:call Reindent(')')<CR><Right>

nmap <buffer> <silent><Leader>jf <Esc>:Pytest file<CR>
nmap <buffer> <silent><Leader>jc <Esc>:Pytest class<CR>
nmap <buffer> <silent><Leader>jm <Esc>:Pytest method<CR>

nmap <buffer> <silent><Leader>jn <Esc>:Pytest next<CR>
nmap <buffer> <silent><Leader>jp <Esc>:Pytest previous<CR>
nmap <buffer> <silent><Leader>je <Esc>:Pytest error<CR>

" a / d
" foo.bar.baz <=> foo["bar"]["baz"]
" f / i
" from foo import bar <=> import foo
nmap <buffer> <silent><LocalLeader>a F[i.<Esc>lds]ds"ds'
nmap <buffer> <silent><LocalLeader>d T.Xysw]lysiw"
nmap <buffer> <silent><LocalLeader>f :s/^import \(\i*\)/from \1 import /<CR>$
nmap <buffer> <silent><LocalLeader>i :s/^from \(\i*\) import .*/import \1/<CR>

vmap <buffer> <silent><LocalLeader>' :s/'/"<CR>

" --------------------- from here on requires +python -------------------------
if !has("python")
    finish
endif

" Add support for virtualenvs
python << EOF
import os
import sys
import vim

virtualenv = os.environ.get("VIRTUAL_ENV")
if virtualenv is not None:
    sys.path.insert(0, virtualenv)
    activate_this = os.path.join(virtualenv, 'bin/activate_this.py')
    execfile(activate_this, dict(__file__=activate_this))
EOF
Something went wrong with that request. Please try again.