Commits

Yuuki Ito  committed beab621

start pycheck.vim

  • Participants

Comments (0)

Files changed (2)

File autoload/pycheck.vim

+if !exists("g:pycheck_list_of_args")
+  let g:pycheck_list_of_args = {
+      \  'pep8': "--repeat",
+      \  'pyflakes': ""
+      \ }
+endif
+
+if !exists("g:pycheck_pyflakes_enable")
+  let g:pycheck_pyflakes_enable = 1
+endif
+
+if !exists("g:pycheck_pep8_enable")
+  let g:pycheck_pep8_enable = 1
+endif
+
+function! s:get_option(type)
+  return g:pycheck_list_of_args[a:type]
+endfunction
+
+function! s:execute_cmd(format, command)
+  let l:old_gfm=&grepformat
+  let l:old_gp=&grepprg
+  let &grepformat=a:format
+  let &grepprg=a:command
+  silent! grep! %
+  let &grepformat=l:old_gfm
+  let &grepprg=l:old_gp
+
+  return getqflist()
+endfunction
+
+function! s:pep8()
+  if !executable("pep8")
+    return
+  endif
+
+  return s:execute_cmd("%f:%l:%c: %m", "pep8 ". s:get_option('pep8'). '')
+endfunction
+
+function! s:pyflakes()
+  if !executable("pyflakes")
+    return
+  endif
+
+  return s:execute_cmd("%f:%l: %m", "pyflakes ". s:get_option('pyflakes'). '')
+endfunction
+
+function! pycheck#run()
+  set lazyredraw
+  cclose
+  let qflist = extend(s:pep8(), s:pyflakes())
+
+  if qflist != []
+    call setqflist(qflist)
+    setlocal wrap
+    execute 'belowright copen'
+  endif
+
+  set nolazyredraw
+  redraw!
+endfunction

File ftplugin/python_pycheck.vim

+autocmd BufWritePost <buffer> call pycheck#run()