Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added supports for ignores #2

Merged
merged 1 commit into from

4 participants

@yifanzhang

in .vimrc, user can specify errors and warnings to ignore:

g:flake8_ignore=E502,W392

@gilsondev

Very cool! I tried to do, but I ended up failing. Where can I find material to explain these settings in Vim?

googled, and experimented a bit. I think most useful stuff is other vim scripts... I am not familiar with vimscript.

@nvie
Owner

Great, thanks for that!

@nvie nvie merged commit 2cf450f into from
@jmlane

Any reason why you wrap the value of the global variable g:flake8_ignore in the script-specific variable s:flake8_ignores? This seemingly just introduces inflexibility, as you are committed to the ignore variable value at python_flake8.vim execution time. Using the global, window, or buffer specific variable values would circumvent this limitation and allow users to change their ignore argument values without having to change their Vim runtime variables.

@yifanzhang

My use of this ignore is to have it in my vimrc, and that's the reason I am using g:. And s: is only used to pass the global variable. Personally, I don't really need other variables than global one. If you think there is something shouldn't be done there, feel free to correct it with pull request.

@jmlane

I'm just curious if there is a technical reason for why we wouldn't want to check the current state of a user-modifiable ignore argument variable at the Flake8() functions execution time? I cannot think of a reason, especially since the current script only passes the global variable to an internal script one, but I'm not well versed in vimscript idiosyncrasies.

I'll see if I can find some clarity on the variable scoping in vimscript and I'll do up a pull request if appropriate.

@yifanzhang

I think it is valid reason. Using g: directly may allow runtime modification. It is not a big concern for me since mostly you are going to stick to one setting (which agreed with every one working on projects). But I do see where your concerns come from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2012
  1. @yifanzhang

    added support for ignores

    yifanzhang authored
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +3 −0  README.mdown
  2. +6 −1 ftplugin/python_flake8.vim
View
3  README.mdown
@@ -41,6 +41,9 @@ enable this, add the following line to your `.vimrc` file (thanks
autocmd BufWritePost *.py call Flake8()
+To ignore errors, in your .vimrc:
+
+ g:flake8_ignore=E501,W293
This plugin goes well together with the following plugin:
View
7 ftplugin/python_flake8.vim
@@ -13,6 +13,11 @@ let b:loaded_flake8_ftplugin=1
let s:flake8_cmd="flake8"
+let s:flake8_ignores=""
+if exists("g:flake8_ignore")
+ let s:flake8_ignores=" --ignore=".g:flake8_ignore
+endif
+
if !exists("*Flake8()")
function Flake8()
if !executable(s:flake8_cmd)
@@ -34,7 +39,7 @@ if !exists("*Flake8()")
" perform the grep itself
let &grepformat="%f:%l:%c: %m\,%f:%l: %m"
- let &grepprg=s:flake8_cmd
+ let &grepprg=s:flake8_cmd.s:flake8_ignores
silent! grep! %
" restore grep settings
Something went wrong with that request. Please try again.