├── README └── plugin └── pep8.vim /README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=2914 2 | 3 | You need to install this tool: http://github.com/cburroughs/pep8.py 4 | It's a simple program that just checks if your python code is pep-8 compliant. 5 | 6 | Pressing F5 will run it using the "quickfix" feature. 7 | This way you can "navigate" through errors using :cn and other standard commands. 8 | 9 | This is mostly copied from http://www.vim.org/scripts/script.php?script_id=891 10 | -------------------------------------------------------------------------------- /plugin/pep8.vim: -------------------------------------------------------------------------------- 1 | " To change mapping, just put 2 | " let g:pep8_map='whatever' 3 | " in your .vimrc 4 | " To change the color of 5 | function! Pep8() 6 | set lazyredraw 7 | " Close any existing cwindows. 8 | cclose 9 | let l:grepformat_save = &grepformat 10 | let l:grepprogram_save = &grepprg 11 | set grepformat&vim 12 | set grepformat&vim 13 | let &grepformat = '%f:%l:%m' 14 | let &grepprg = 'pep8 --repeat' 15 | if &readonly == 0 | update | endif 16 | silent! grep! % 17 | let &grepformat = l:grepformat_save 18 | let &grepprg = l:grepprogram_save 19 | let l:mod_total = 0 20 | let l:win_count = 1 21 | " Determine correct window height 22 | windo let l:win_count = l:win_count + 1 23 | if l:win_count <= 2 | let l:win_count = 4 | endif 24 | windo let l:mod_total = l:mod_total + winheight(0)/l:win_count | 25 | \ execute 'resize +'.l:mod_total 26 | " Open cwindow 27 | execute 'belowright copen '.l:mod_total 28 | nnoremap c :cclose 29 | set nolazyredraw 30 | redraw! 31 | let tlist=getqflist() ", 'get(v:val, ''bufnr'')') 32 | if empty(tlist) 33 | if !hlexists('GreenBar') 34 | hi GreenBar term=reverse ctermfg=white ctermbg=darkgreen guifg=white guibg=darkgreen 35 | endif 36 | echohl GreenBar 37 | echomsg "PEP8 correct" 38 | echohl None 39 | cclose 40 | endif 41 | endfunction 42 | 43 | if !exists('g:pep8_map') 44 | let g:pep8_map='' 45 | endif 46 | if ( !hasmapto('PEP8()') && (maparg(g:pep8_map) == '') ) 47 | exe 'nnoremap '. g:pep8_map .' :call Pep8()' 48 | " map :call Pep8() 49 | " map! :call Pep8() 50 | else 51 | if ( !has("gui_running") || has("win32") ) 52 | echo "Python PEP8 Error: No Key mapped.\n". 53 | \ g:pep8_map ." is taken and a replacement was not assigned." 54 | endif 55 | endif 56 | 57 | --------------------------------------------------------------------------------