Browse Source

Installed pep8 0.3.1

*   http://www.vim.org/scripts/script.php?script_id=2914
Alois Mahdal 11 years ago
parent
commit
86054d239b
1 changed files with 56 additions and 0 deletions
  1. 56
    0
      dotfiles/vim/bundle/pep8/ftplugin/python/pep8.vim

+ 56
- 0
dotfiles/vim/bundle/pep8/ftplugin/python/pep8.vim View File

@@ -0,0 +1,56 @@
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
+
43
+  if !exists('g:pep8_map')
44
+    let g:pep8_map='<F5>'
45
+  endif
46
+if ( !hasmapto('<SID>PEP8()') && (maparg(g:pep8_map) == '') )
47
+  exe 'nnoremap <silent> '. g:pep8_map .' :call <SID>Pep8()<CR>'
48
+"  map <F5> :call <SID>Pep8()<CR>
49
+"  map! <F5> :call <SID>Pep8()<CR>
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
+