Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions autoload/pymode/folding.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,25 @@ let s:symbol = matchstr(&fillchars, 'fold:\zs.') " handles multibyte characters
if s:symbol == ''
let s:symbol = ' '
endif
let foldtextprev=foldtext()

fun! pymode#folding#enable() " {{{
setlocal foldmethod=expr
setlocal foldexpr=pymode#folding#expr(v:lnum)
setlocal foldtext=pymode#folding#text()
endfunction "}}}

fun! pymode#folding#disable() " {{{
" setlocal foldmethod=expr
setlocal foldexpr="0"
setlocal foldtext=&foldtextprev
endfunction "}}}

fun! pymode#folding#text() " {{{
if &diff
call pymode#folding#disable()
return
endif
let fs = v:foldstart
while getline(fs) !~ s:def_regex && getline(fs) !~ s:doc_begin_regex
let fs = nextnonblank(fs + 1)
Expand All @@ -40,6 +56,9 @@ endfunction "}}}


fun! pymode#folding#expr(lnum) "{{{
if &diff
pymode#folding#disable()
endif

let line = getline(a:lnum)
let indent = indent(a:lnum)
Expand Down
2 changes: 1 addition & 1 deletion doc/pymode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ imported) from project *'g:pymode_rope_autoimport'*

Load modules to autoimport by default *'g:pymode_rope_autoimport_modules'*
>
let g:pymode_rope_autoimport_modules = ['os', 'shutil', 'datetime'])
let g:pymode_rope_autoimport_modules = ['os', 'shutil', 'datetime']

Offer to unresolved import object after completion.
>
Expand Down
7 changes: 4 additions & 3 deletions ftplugin/python/pymode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ endif
" Python folding
if g:pymode_folding

setlocal foldmethod=expr
setlocal foldexpr=pymode#folding#expr(v:lnum)
setlocal foldtext=pymode#folding#text()
" setlocal foldmethod=expr
" setlocal foldexpr=pymode#folding#expr(v:lnum)
" setlocal foldtext=pymode#folding#text()
call pymode#folding#enable()

endif

Expand Down
4 changes: 4 additions & 0 deletions pymode/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .utils import silence_stderr

import os.path
import vim


from pylama.lint.extensions import LINTERS
Expand Down Expand Up @@ -37,6 +38,9 @@ def code_check():
ignore=env.var('g:pymode_lint_ignore'),
select=env.var('g:pymode_lint_select'),
)
linters_keys = [l[0] for l in options.linters]
if vim.current.buffer.options['modified'] and 'pylint' in linters_keys:
del options.linters[linters_keys.index('pylint')]

for linter in linters:
opts = env.var('g:pymode_lint_options_%s' % linter, silence=True)
Expand Down
33 changes: 29 additions & 4 deletions t/lint.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source plugin/pymode.vim
source plugin/pymode.vim

describe 'pymode check code'

Expand All @@ -15,16 +15,41 @@ describe 'pymode check code'
end

it 'lint new'
put =['# coding: utf-8', 'call_unknown_function()']
put =['# coding: utf-8', 'x = 1']
PymodeLint
Expect getloclist(0) == []
end

it 'lint code'
e t/test.py
PymodeLint
Expect getloclist(0) == [{'lnum': 6, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'W0612 local variable "unused" is assigned to but never used [pyflakes]'}, {'lnum': 8, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'E0602 undefined name "unknown" [pyflakes]'}]
let ll = getloclist(0)

Expect len(ll) == 4

Expect ll[0]['lnum'] == 1
Expect ll[0]['col'] == 0
Expect ll[0]['valid'] == 1
Expect ll[0]['type'] == 'C'
Expect ll[0]['text'] == "C0111 Missing module docstring [pylint]"

Expect ll[1]['lnum'] == 5
Expect ll[1]['col'] == 0
Expect ll[1]['valid'] == 1
Expect ll[1]['type'] == 'C'
Expect ll[1]['text'] == "C0111 Missing function docstring [pylint]"

Expect ll[2]['lnum'] == 6
Expect ll[2]['col'] == 7
Expect ll[2]['valid'] == 1
Expect ll[2]['type'] == 'C'
Expect ll[2]['text'] == "E225 missing whitespace around operator [pep8]"

Expect ll[3]['lnum'] == 9
Expect ll[3]['col'] == 0
Expect ll[3]['valid'] == 1
Expect ll[3]['type'] == 'E'
Expect ll[3]['text'] == "E0602 Undefined variable 'unknown' [pylint]"
end

end

6 changes: 4 additions & 2 deletions t/plugin.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe 'pymode-plugin'

before
source plugin/pymode.vim
source plugin/pymode.vim
set filetype=python
end

Expand All @@ -28,6 +28,8 @@ describe 'pymode-plugin'
end

it 'pymode save'
bd!
bd!
Expect expand('%') == ''
Expect pymode#save() == 0
end
Expand All @@ -38,7 +40,7 @@ end
describe 'pymode-python-disable'
before
let g:pymode_python = 'disable'
source plugin/pymode.vim
source plugin/pymode.vim
set filetype=python
end

Expand Down
13 changes: 4 additions & 9 deletions t/rope.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let g:pymode_rope_autoimport = 0
let g:pymode_debug = 1
let g:pymode_rope_lookup_project = 0

source plugin/pymode.vim
source plugin/pymode.vim

describe 'pymode-plugin'

Expand All @@ -17,17 +17,12 @@ describe 'pymode-plugin'
end

it 'pymode rope auto open project in current working directory'

if $TRAVIS != ""
SKIP 'Travis fails on this test'
endif

let project_path = getcwd() . '/.ropeproject'
let project_path = getcwd() . system("mktemp -u /.ropeproject.XXXXXX | tr -d '\n'")
Expect isdirectory(project_path) == 0
let g:pymode_rope_project_root = project_path
normal oimporX
Expect getline('.') == 'import'
Expect g:pymode_rope_current == getcwd() . '/'
Expect g:pymode_rope_current . '.ropeproject' == project_path
Expect g:pymode_rope_current == project_path . '/'
Expect isdirectory(project_path) == 1
end

Expand Down
3 changes: 2 additions & 1 deletion t/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


def main():
unused = 1
rc=1
return rc

unknown()