]> git.madduck.net Git - etc/vim.git/blob - README.mdown

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

add option for customizing quickfix window height
[etc/vim.git] / README.mdown
1 vim-flake8
2 ==========
3 `vim-flake8` is a Vim plugin that runs the currently open file through Flake8,
4 a static syntax and style checker for Python source code.  It supersedes both
5 [vim-pyflakes](https://github.com/nvie/vim-pyflakes) and
6 [vim-pep8](https://github.com/nvie/vim-pep8).
7
8 [Flake8](http://pypi.python.org/pypi/flake8/) is a wrapper around PyFlakes 
9 (static syntax checker), PEP8 (style checker) 
10 and Ned's MacCabe script (complexity checker).
11
12
13 Installation
14 ------------
15 Use [vim-pathogen](https://github.com/tpope/vim-pathogen) if you're not using
16 it already.  Make sure you've installed the [flake8](http://pypi.python.org/pypi/flake8/) package.
17 Then, simply put the contents of this repository in your
18 `~/.vim/bundle` directory.
19
20 Usage
21 -----
22 1. Open a Python file
23 2. Press `<F7>` to run `flake8` on it
24
25 It shows the errors inside a quickfix window, which will allow your to quickly
26 jump to the error locations by simply pressing [Enter].
27
28 If any of `g:flake8_show_in_gutter` or `g:flake8_show_in_file` are set to `1`, call:
29
30     call flake8#Flake8UnplaceMarkers()
31
32 To remove all markers. No default mapping is provided.
33
34 Customization
35 -------------
36 If you don't want to use the `<F7>` key for flake8-checking, simply remap it to
37 another key.  It autodetects whether it has been remapped and won't register
38 the `<F7>` key if so.  For example, to remap it to `<F3>` instead, use:
39
40     autocmd FileType python map <buffer> <F3> :call Flake8()<CR>
41
42 To add builtins, in your .vimrc:
43
44     let g:flake8_builtins="_,apply"
45
46 To ignore errors, in your .vimrc:
47
48     let g:flake8_ignore="E501,W293"
49
50 If you want to change the max line length for PEP8:
51
52     let g:flake8_max_line_length=99
53
54 To set the maximum [McCabe complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) before a warning is issued:
55
56     let g:flake8_max_complexity=10
57
58 To customize the location of your flake8 binary, set `g:flake8_cmd`:
59
60     let g:flake8_cmd="/opt/strangebin/flake8000"
61
62 To customize the location of quick fix window, set `g:flake8_quickfix_location`:
63
64     let g:flake8_quickfix_location="topleft"
65
66 To customize the height of quick fix window, set `g:flake8_quickfix_height`:
67
68     let g:flake8_quickfix_height=7
69
70 To customize whether the quickfix window opens, set `g:flake8_show_quickfix`:
71
72     let g:flake8_show_quickfix=0  " don't show
73     let g:flake8_show_quickfix=1  " show (default)
74
75 To customize whether the show signs in the gutter, set `g:flake8_show_in_gutter`:
76
77     let g:flake8_show_in_gutter=0  " don't show (default)
78     let g:flake8_show_in_gutter=1  " show
79
80 To customize whether the show marks in the file, set `g:flake8_show_in_file`:
81
82     let g:flake8_show_in_file=0  " don't show (default)
83     let g:flake8_show_in_file=1  " show
84
85 To customize the number of marks to show, set `g:flake8_max_markers`:
86
87     let g:flake8_max_markers=500  " (default)
88
89 To customize the gutter markers, set any of `flake8_error_marker`, `flake8_warning_marker`,
90 `flake8_pyflake_marker`, `flake8_complexity_marker`, `flake8_naming_marker`. Setting one to
91 the empty string disables it. Ex.:
92
93     flake8_error_marker='EE'     " set error marker to 'EE'
94     flake8_warning_marker='WW'   " set warning marker to 'WW'
95     flake8_pyflake_marker=''     " disable PyFlakes warnings
96     flake8_complexity_marker=''  " disable McCabe complexity warnings
97     flake8_naming_marker=''      " disable naming warnings
98
99 To customize the colors used for markers, define the highlight groups, `Flake8_Error`,
100 `Flake8_Warning`, `Flake8_PyFlake`, `Flake8_Complexity`, `Flake8_Naming`:
101
102     " to use colors defined in the colorscheme
103     highlight link Flake8_Error      Error
104     highlight link Flake8_Warning    WarningMsg
105     highlight link Flake8_Complexity WarningMsg
106     highlight link Flake8_Naming     WarningMsg
107     highlight link Flake8_PyFlake    WarningMsg
108
109 Tips
110 ----
111 A tip might be to run the Flake8 check every time you write a Python file, to
112 enable this, add the following line to your `.vimrc` file (thanks
113 [Godefroid](http://github.com/gotcha)!):
114
115     autocmd BufWritePost *.py call Flake8()
116
117 This plugin goes well together with the following plugin:
118
119 - [PyUnit](http://github.com/nvie/vim-pyunit) (unit test helper under `<F8>`
120   and `<F9>`)
121
122
123 History
124 -------
125
126 1.5: Added markers and the option to don't show the quickfix window, also split functions into
127 a autoload file. Added:
128
129     - Options:
130       - `g:flake8_show_quickfix`
131       - `g:flake8_show_in_gutter`
132       - `g:flake8_show_in_file`
133       - `g:flake8_max_markers`
134       - `flake8_error_marker`
135       - `flake8_warning_marker`
136       - `flake8_pyflake_marker`
137       - `flake8_complexity_marker`
138       - `flake8_naming_marker`
139     - Functions:
140       - `flake8#Flake8UnplaceMarkers()`
141       - `flake8#Flake8()`
142     - Highlighting:
143       - `Flake8_Error`
144       - `Flake8_Warning`
145       - `Flake8_Complexity`
146       - `Flake8_Naming`
147       - `Flake8_PyFlake`
148
149 1.4: Suppress output to stdout.
150
151 1.3: Added the following options:
152
153     - `g:flake8_builtins="_,apply"`
154     - `g:flake8_max_complexity=10`
155
156 1.2: Added the following options:
157
158     - `g:flake8_cmd="/opt/strangebin/flake8000"`
159     - `g:flake8_max_line_length=120`
160     - `g:flake8_ignore="E501,W293"`
161
162 1.1: Added `g:flake8_ignore` option.
163
164 1.0: Initial version.
165
166
167 License
168 -------
169
170 Liberally licensed under BSD terms.