Browse files

Merge branch 'master' of http://github.com/phuihock/pyflakes-vim into…

… quickfix
  • Loading branch information...
2 parents 80e1680 + 5529f1c commit 64ebcffe3de49fe34ca12b11292b792dc323709f @kevinw committed Jul 21, 2010
Showing with 49 additions and 4 deletions.
  1. +2 −2 README.rst
  2. +47 −2 pyflakes.vim
View
4 README.rst
@@ -8,11 +8,13 @@ accessing a local before it is bound, and also gives warnings for things like
unused imports.
pyflakes-vim uses the output from PyFlakes to highlight errors in your code.
+To locate errors quickly, use quickfix_ commands:
Make sure to check vim.org_ for the latest updates.
.. _pyflakes.vim: http://www.vim.org/scripts/script.php?script_id=2441
.. _vim.org: http://www.vim.org/scripts/script.php?script_id=2441
+.. _quickfix: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
Quick Installation
------------------
@@ -57,12 +59,10 @@ Hacking
TODO
----
* signs_ support (show warning and error icons to left of the buffer area)
- * quickfix_ support (allow jumping forward and back through the error list)
* configuration variables
* parse or intercept useful output from the warnings module
.. _signs: http://www.vim.org/htmldoc/sign.html
-.. _quickfix: http://vimdoc.sourceforge.net/htmldoc/quickfix.html
Changelog
---------
View
49 pyflakes.vim
@@ -159,6 +159,42 @@ if !exists("*s:WideMsg")
endfun
endif
+if !exists("*s:GetQuickFixStackCount")
+ function s:GetQuickFixStackCount()
+ let l:stack_count = 0
+ try
+ silent colder 9
+ catch /E380:/
+ endtry
+
+ try
+ for i in range(9)
+ silent cnewer
+ let l:stack_count = l:stack_count + 1
+ endfor
+ catch /E381:/
+ return l:stack_count
+ endtry
+ endfunction
+endif
+
+if !exists("*s:ActivatePyflakesQuickFixWindow")
+ function s:ActivatePyflakesQuickFixWindow()
+ try
+ silent colder 9 " go to the bottom of quickfix stack
+ catch /E380:/
+ endtry
+
+ if s:pyflakes_qf > 0
+ try
+ exe "silent cnewer " . s:pyflakes_qf
+ catch /E381:/
+ echoerr "Could not activate Pyflakes Quickfix Window."
+ endtry
+ endif
+ endfunction
+endif
+
if !exists("*s:RunPyflakes")
function s:RunPyflakes()
highlight link PyFlakes SpellBad
@@ -176,6 +212,8 @@ if !exists("*s:RunPyflakes")
let b:matchedlines = {}
let b:qf_list = []
+ let b:qf_window_count = -1
+
python << EOF
for w in check(vim.current.buffer):
vim.command('let s:matchDict = {}')
@@ -203,9 +241,16 @@ for w in check(vim.current.buffer):
vim.command("call add(b:matched, s:matchDict)")
vim.command("call add(b:qf_list, l:qf_item)")
-
-vim.command("call setqflist(b:qf_list, 'r')")
EOF
+ if exists("s:pyflakes_qf")
+ " if pyflakes quickfix window is already created, reuse it
+ call s:ActivatePyflakesQuickFixWindow()
+ call setqflist(b:qf_list, 'r')
+ else
+ " one pyflakes quickfix window for all buffer
+ call setqflist(b:qf_list, '')
+ let s:pyflakes_qf = s:GetQuickFixStackCount()
+ endif
let b:cleared = 0
endfunction
end

0 comments on commit 64ebcff

Please sign in to comment.