Move all functions for fixing things to autoload/ale/fixers, and only accept the lines of input where needed.

This commit is contained in:
w0rp
2017-06-07 14:02:29 +01:00
parent edddb1910b
commit 7517fd8226
15 changed files with 132 additions and 98 deletions

View File

@@ -0,0 +1,22 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Generic fixer functions for Python.
" Add blank lines before control statements.
function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort
let l:new_lines = []
let l:last_indent_size = 0
for l:line in a:lines
let l:indent_size = len(matchstr(l:line, '^ *'))
if l:indent_size <= l:last_indent_size
\&& match(l:line, '\v^ *(return|if|for|while|break|continue)') >= 0
call add(l:new_lines, '')
endif
call add(l:new_lines, l:line)
let l:last_indent_size = l:indent_size
endfor
return l:new_lines
endfunction