summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorKevin Locke <kevin@kevinlocke.name>2019-02-08 21:44:34 +0000
committerw0rp <w0rp@users.noreply.github.com>2019-02-08 21:44:34 +0000
commita24f0b4d5f91f9214c64ae281fadcd981e0dadfc (patch)
tree25e07c98b5de66ab70db85b980fcbe9f3675358d /autoload
parent422908a5721e11be73935b765f599f9fc672802e (diff)
downloadale-a24f0b4d5f91f9214c64ae281fadcd981e0dadfc.zip
Support pylama for python (#2266)
* Add pylama for python * Consolidate python traceback handling
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/python.vim39
1 files changed, 39 insertions, 0 deletions
diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index 5c569561..c911c046 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -27,6 +27,7 @@ function! ale#python#FindProjectRootIni(buffer) abort
\|| filereadable(l:path . '/pycodestyle.cfg')
\|| filereadable(l:path . '/flake8.cfg')
\|| filereadable(l:path . '/.flake8rc')
+ \|| filereadable(l:path . '/pylama.ini')
\|| filereadable(l:path . '/Pipfile')
\|| filereadable(l:path . '/Pipfile.lock')
return l:path
@@ -110,6 +111,44 @@ function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort
return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
+" Handle traceback.print_exception() output starting in the first a:limit lines.
+function! ale#python#HandleTraceback(lines, limit) abort
+ let l:nlines = len(a:lines)
+ let l:limit = a:limit > l:nlines ? l:nlines : a:limit
+ let l:start = 0
+
+ while l:start < l:limit
+ if a:lines[l:start] is# 'Traceback (most recent call last):'
+ break
+ endif
+
+ let l:start += 1
+ endwhile
+
+ if l:start >= l:limit
+ return []
+ endif
+
+ let l:end = l:start + 1
+
+ " Traceback entries are always prefixed with 2 spaces.
+ " SyntaxError marker (if present) is prefixed with at least 4 spaces.
+ " Final exc line starts with exception class name (never a space).
+ while l:end < l:nlines && a:lines[l:end][0] is# ' '
+ let l:end += 1
+ endwhile
+
+ let l:exc_line = l:end < l:nlines
+ \ ? a:lines[l:end]
+ \ : 'An exception was thrown.'
+
+ return [{
+ \ 'lnum': 1,
+ \ 'text': l:exc_line . ' (See :ALEDetail)',
+ \ 'detail': join(a:lines[(l:start):(l:end)], "\n"),
+ \}]
+endfunction
+
" Detects whether a pipenv environment is present.
function! ale#python#PipenvPresent(buffer) abort
return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# ''