My dotfiles. Period.

pep8.vim 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. " To change mapping, just put
  2. " let g:pep8_map='whatever'
  3. " in your .vimrc
  4. " To change the color of
  5. function! <SID>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 <buffer> <silent> c :cclose<CR>
  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. if !exists('g:pep8_map')
  43. let g:pep8_map='<F8>'
  44. endif
  45. if ( !hasmapto('<SID>PEP8()') && (maparg(g:pep8_map) == '') )
  46. exe 'nnoremap <silent> '. g:pep8_map .' :call <SID>Pep8()<CR>'
  47. " map <F8> :call <SID>Pep8()<CR>
  48. " map! <F8> :call <SID>Pep8()<CR>
  49. else
  50. if ( !has("gui_running") || has("win32") )
  51. echo "Python PEP8 Error: No Key mapped.\n".
  52. \ g:pep8_map ." is taken and a replacement was not assigned."
  53. endif
  54. endif