Full tunning with code checkers. Also added g:pymode_options_max_line… · python-canux/python-mode@00c6c75 · GitHub
Skip to content

Commit 00c6c75

Browse files
committed
Full tunning with code checkers. Also added g:pymode_options_max_line_length
1 parent e5f1486 commit 00c6c75

7 files changed

Lines changed: 93 additions & 11 deletions

File tree

Changelog.rst

Lines changed: 5 additions & 0 deletions

autoload/pymode/tools/loclist.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fun! g:PymodeLocList.show() "{{{
7171
else
7272
let num = winnr()
7373
lopen
74+
setl nowrap
7475
execute max([min([line("$"), g:pymode_quickfix_maxheight]), g:pymode_quickfix_minheight]) . "wincmd _"
7576
if num != winnr()
7677
call setwinvar(winnr(), 'quickfix_title', self._title . ' <' . self._name . '>')

doc/pymode.txt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ CONTENTS *pymode-contents*
2222
2.7 Run code................................................|pymode-run|
2323
2.8 Breakpoints.....................................|pymode-breakpoints|
2424
3. Code checking...............................................|pymode-lint|
25+
3.1 Code checkers options..........................|pymode-lint-options|
2526
4. Rope support................................................|pymode-rope|
2627
4.1 Code completion..................................|pymode-completion|
2728
4.2 Find definition.................................|pymode-rope-findit|
@@ -89,14 +90,18 @@ Value is list of path's strings.
8990
>
9091
let g:pymode_paths = []
9192
92-
Trim unused white spaces on save *'g:pymode_trim_whitespaces'*
93+
Trim unused white spaces on save *'g:pymode_trim_whitespaces'*
9394
>
9495
let g:pymode_trim_whitespaces = 1
9596
9697
Setup default python options *'g:pymode_options'*
9798
>
9899
let g:pymode_options = 1
99100
101+
Setup max line length *'g:pymode_options_max_line_length'*
102+
>
103+
let g:pymode_options_max_line_length = 79
104+
100105
If this option is set to 1, pymode will enable the following options for
101106
python buffers: >
102107
@@ -330,6 +335,40 @@ Definitions for |signs|
330335
let g:pymode_lint_info_symbol = 'II'
331336
let g:pymode_lint_pyflakes_symbol = 'FF'
332337
338+
------------------------------------------------------------------------------
339+
3.1 Set code checkers options ~
340+
*pymode-lint-options*
341+
342+
Pymode has the ability to set code checkers options from pymode variables:
343+
344+
Set PEP8 options *'g:pymode_lint_options_pep8'*
345+
>
346+
let g:pymode_lint_options_pep8 =
347+
\ {'max_line_length': g:pymode_options_max_line_length})
348+
349+
See https://pep8.readthedocs.org/en/1.4.6/intro.html#configuration for more
350+
info.
351+
352+
Set Pyflakes options *'g:pymode_lint_options_pyflakes'*
353+
>
354+
let g:pymode_lint_options_pyflakes = { 'builtins': '_' }
355+
356+
Set mccabe options *'g:pymode_lint_options_mccabe'*
357+
>
358+
let g:pymode_lint_options_mccabe = { 'complexity': 12 }
359+
360+
Set pep257 options *'g:pymode_lint_options_pep257'*
361+
>
362+
let g:pymode_lint_options_pep257 = {}
363+
364+
Set pylint options *'g:pymode_lint_options_pylint'*
365+
>
366+
let g:pymode_lint_options_pylint =
367+
\ {'max-line-length': g:pymode_options_max_line_length})
368+
369+
See http://docs.pylint.org/features.html#options for more info.
370+
371+
333372

334373
==============================================================================
335374
3. Rope support ~

ftplugin/python/pymode.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ if g:pymode_options
5656
setlocal number
5757
endif
5858
setlocal nowrap
59-
setlocal textwidth=79
59+
exe "setlocal textwidth=" . g:pymode_options_max_line_length
60+
if exists('+colorcolumn')
61+
setlocal colorcolumn=+1
62+
endif
6063
setlocal commentstring=#%s
6164
setlocal define=^\s*\\(def\\\\|class\\)
6265
endif

plugin/pymode.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ call pymode#default("g:pymode_trim_whitespaces", 1)
4747

4848
" Set recomended python options
4949
call pymode#default("g:pymode_options", 1)
50+
call pymode#default("g:pymode_options_max_line_length", 80)
5051

5152
" Minimal height of pymode quickfix window
5253
call pymode#default('g:pymode_quickfix_maxheight', 6)
@@ -127,6 +128,20 @@ call pymode#default("g:pymode_lint_error_symbol", "EE")
127128
call pymode#default("g:pymode_lint_info_symbol", "II")
128129
call pymode#default("g:pymode_lint_pyflakes_symbol", "FF")
129130

131+
" Code checkers options
132+
call pymode#default("g:pymode_lint_options_pep8",
133+
\ {'max_line_length': g:pymode_options_max_line_length})
134+
135+
call pymode#default("g:pymode_lint_options_pylint",
136+
\ {'max-line-length': g:pymode_options_max_line_length})
137+
138+
call pymode#default("g:pymode_lint_options_mccabe",
139+
\ {'complexity': 12})
140+
141+
call pymode#default("g:pymode_lint_options_pep257", {})
142+
call pymode#default("g:pymode_lint_options_pyflakes", { 'builtins': '_' })
143+
144+
130145
" }}}
131146

132147
" SET/UNSET BREAKPOINTS {{{

pymode/environment.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,19 @@ def lines(self):
5858

5959
return [l.decode(self.options.get('encoding')) for l in self.curbuf]
6060

61-
def var(self, name, to_bool=False):
61+
@staticmethod
62+
def var(name, to_bool=False, silence=False):
6263
""" Get vim variable.
6364
6465
:return vimobj:
6566
6667
"""
67-
value = vim.eval(name)
68+
try:
69+
value = vim.eval(name)
70+
except vim.error:
71+
if silence:
72+
return None
73+
raise
6874

6975
if to_bool:
7076
try:
@@ -73,7 +79,8 @@ def var(self, name, to_bool=False):
7379
value = value
7480
return value
7581

76-
def message(self, msg, history=False):
82+
@staticmethod
83+
def message(msg, history=False):
7784
""" Show message to user.
7885
7986
:return: :None
@@ -139,7 +146,8 @@ def user_input_choices(self, msg, *options):
139146
self.error('Invalid option: %s' % input_str)
140147
return self.user_input_choices(msg, *options)
141148

142-
def error(self, msg):
149+
@staticmethod
150+
def error(msg):
143151
""" Show error to user. """
144152
vim.command('call pymode#error("%s")' % str(msg))
145153

@@ -218,7 +226,8 @@ def get_offset_params(self, cursor=None, base=""):
218226
env.debug('Get offset', base or None, row, col, offset)
219227
return source, offset
220228

221-
def goto_line(self, line):
229+
@staticmethod
230+
def goto_line(line):
222231
""" Go to line. """
223232
vim.command('normal %sggzz' % line)
224233

@@ -228,7 +237,8 @@ def goto_file(self, path, cmd='e', force=False):
228237
self.debug('read', path)
229238
vim.command("%s %s" % (cmd, path))
230239

231-
def goto_buffer(self, bufnr):
240+
@staticmethod
241+
def goto_buffer(bufnr):
232242
""" Open buffer. """
233243
if str(bufnr) != '-1':
234244
vim.command('buffer %s' % bufnr)

pymode/lint.py

Lines changed: 12 additions & 3 deletions

0 commit comments

Comments
 (0)