Skip to content

Commit 6d280c6

Browse files
committed
Fix docs, add g:pymode_lint_async option
1 parent dde90e7 commit 6d280c6

File tree

6 files changed

+67
-6
lines changed

6 files changed

+67
-6
lines changed

autoload/pymode/doc.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ fun! pymode#doc#Show(word) "{{{
88
Python import StringIO
99
Python sys.stdout, _ = StringIO.StringIO(), sys.stdout
1010
Python help(vim.eval('a:word'))
11-
call pymode#TempBuffer()
11+
Python sys.stdout, out = _, sys.stdout.getvalue()
12+
if !g:pymode_test
13+
call pymode#TempBuffer()
14+
endif
1215
Python vim.current.buffer.append(str(out).splitlines(), 0)
1316
wincmd p
1417
endif

ftplugin/python/init-pymode.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ if pymode#Default('g:pymode_init', 1)
22
finish
33
endif
44

5+
call pymode#Default('g:pymode_test', 0)
6+
57
let g:pymode_version = "0.6.18"
68

79
com! PymodeVersion echomsg "Current python-mode version: " . g:pymode_version
@@ -62,6 +64,9 @@ if !pymode#Default("g:pymode_lint", 1) || g:pymode_lint
6264
" OPTION: g:pymode_lint_write -- bool. Check code every save.
6365
call pymode#Default("g:pymode_lint_write", 1)
6466

67+
" OPTION: g:pymode_lint_async -- bool. Run a checkers asynchronously
68+
call pymode#Default("g:pymode_lint_async", 1)
69+
6570
" OPTION: g:pymode_lint_onfly -- bool. Check code every save.
6671
call pymode#Default("g:pymode_lint_onfly", 0)
6772

pylibs/pymode/lint.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def check_file():
2121
""" Check current buffer. """
2222
buf = interface.get_current_buffer()
2323

24+
async = int(interface.get_option('lint_async'))
2425
linters = interface.get_option('lint_checker')
2526
ignore = interface.get_option('lint_ignore')
2627
select = interface.get_option('lint_select')
@@ -29,10 +30,15 @@ def check_file():
2930
options = parse_options(
3031
ignore=ignore, select=select, complexity=complexity, linters=linters)
3132

32-
add_task(
33-
run_checkers, callback=parse_result, title='Code checking', buf=buf,
34-
options=options,
35-
)
33+
if async:
34+
add_task(
35+
run_checkers, callback=parse_result, title='Code checking',
36+
buf=buf, options=options,
37+
)
38+
39+
else:
40+
result = run_checkers(buf=buf, options=options)
41+
parse_result(result, buf=buf)
3642

3743

3844
def run_checkers(callback=None, buf=None, options=None):

t/pymode.vim renamed to t/base.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
filetype plugin indent on
2+
set hidden
23

34
describe 'pymode'
45

@@ -18,7 +19,6 @@ describe 'pymode'
1819
e test.py
1920
Python vim.current.buffer.append('Python is working.', 0)
2021
Expect getline(1) == 'Python is working.'
21-
w
2222
end
2323

2424
end

t/docs.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
filetype plugin indent on
2+
set hidden
3+
4+
describe 'docs'
5+
before
6+
e t/test.py
7+
let g:pymode_test = 1
8+
end
9+
10+
it 'pymode show docs'
11+
Pydoc def
12+
Expect getline(1) == 'Function definitions'
13+
Expect 1 == 1
14+
end
15+
16+
end
17+

t/lint.vim

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
filetype plugin indent on
2+
set hidden
3+
4+
describe 'pymode check code'
5+
6+
before
7+
e t/test.py
8+
end
9+
10+
after
11+
close
12+
end
13+
14+
it 'async'
15+
let g:pymode_lint_async = 1
16+
PyLint
17+
Expect getqflist() == []
18+
sleep 1
19+
call pymode#queue#Poll()
20+
Expect getqflist() == [{'lnum': 2, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'W0612 local variable "test" is assigned to but never used [pyflakes]'}]
21+
end
22+
23+
it 'disable async'
24+
let g:pymode_lint_async = 0
25+
PyLint
26+
Expect getqflist() == [{'lnum': 2, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'W0612 local variable "test" is assigned to but never used [pyflakes]'}]
27+
end
28+
29+
end
30+

0 commit comments

Comments
 (0)