\ ? call(l:Function, [l:buffer, a:options.output])
\ : call(l:Function, [l:buffer, a:options.output, copy(l:input)])
else
- " Chained commands accept (buffer, [input])
+ " Chained commands accept (buffer, [done, input])
let l:result = ale#util#FunctionArgCount(l:Function) == 1
\ ? call(l:Function, [l:buffer])
- \ : call(l:Function, [l:buffer, copy(l:input)])
+ \ : call(l:Function, [l:buffer, v:null, copy(l:input)])
endif
if type(l:result) is v:t_number && l:result == 0
" Author: w0rp <devw0rp@gmail.com>
" Description: Generic functions for fixing files with.
-function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort
+function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort
let l:end_index = len(a:lines) - 1
while l:end_index > 0 && empty(a:lines[l:end_index])
endfunction
" Remove all whitespaces at the end of lines
-function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort
+function! ale#fixers#generic#TrimWhitespace(buffer, done, lines) abort
let l:index = 0
let l:lines_new = range(len(a:lines))
" Description: Generic fixer functions for Python.
" Add blank lines before control statements.
-function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort
+function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, done, lines) abort
let l:new_lines = []
let l:last_indent_size = 0
let l:last_line_is_blank = 0
" This function breaks up long lines so that autopep8 or other tools can
" fix the badly-indented code which is produced as a result.
-function! ale#fixers#generic_python#BreakUpLongLines(buffer, lines) abort
+function! ale#fixers#generic_python#BreakUpLongLines(buffer, done, lines) abort
" Default to a maximum line length of 79
let l:max_line_length = 79
let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg')
" Author: w0rp <devw0rp@gmail.com>
" Description: Generic fixer functions for Vim help documents.
-function! ale#fixers#help#AlignTags(buffer, lines) abort
+function! ale#fixers#help#AlignTags(buffer, done, lines) abort
let l:new_lines = []
for l:line in a:lines
for a function set in the ALE fixer registry.
Each function for fixing errors must accept either one argument `(buffer)` or
-two arguments `(buffer, lines)`, representing the buffer being fixed and the
-lines to fix. The functions must return either `0`, for changing nothing, a
-|List| for new lines to set, or a |Dictionary| for describing a command to be
-run in the background.
+three arguments `(buffer, done, lines)`, representing the buffer being fixed,
+a function to call with results, and the lines to fix. The functions must
+return either `0`, for changing nothing, a |List| for new lines to set, a
+|Dictionary| for describing a command to be run in the background, or `v:true`
+for indicating that results will be provided asynchronously via the `done`
+callback.
+
+NOTE: The `done` function has not been implemented yet.
Functions receiving a variable number of arguments will not receive the second
argument `lines`. Functions should name two arguments if the `lines` argument
call ale#test#SetFilename('test.txt')
call ale#linter#PreventLoading('testft')
- function AddCarets(buffer, lines) abort
+ function AddCarets(buffer, done, lines) abort
" map() is applied to the original lines here.
" This way, we can ensure that defensive copies are made.
return map(a:lines, '''^'' . v:val')
endfunction
- function AddDollars(buffer, lines) abort
+ function AddDollars(buffer, done, lines) abort
return map(a:lines, '''$'' . v:val')
endfunction
- function DoNothing(buffer, lines) abort
+ function DoNothing(buffer, done, lines) abort
return 0
endfunction
- function CatLine(buffer, lines) abort
+ function CatLine(buffer, done, lines) abort
return {'command': 'cat - <(echo d)'}
endfunction
return {'command': 'cat - <(echo d)'}
endfunction
- function ReplaceWithTempFile(buffer, lines) abort
+ function ReplaceWithTempFile(buffer, done, lines) abort
return {'command': 'echo x > %t', 'read_temporary_file': 1}
endfunction
- function RemoveLastLine(buffer, lines) abort
+ function RemoveLastLine(buffer, done, lines) abort
return ['a', 'b']
endfunction
endfunction
" echo will output a single blank line, and we should ingore it.
- function! IgnoredEmptyOutput(buffer, output)
+ function! IgnoredEmptyOutput(buffer, done, output)
return {'command': has('win32') ? 'echo(' : 'echo'}
endfunction
- function! EchoLineNoPipe(buffer, output)
+ function! EchoLineNoPipe(buffer, done, output)
return {'command': 'echo new line', 'read_buffer': 0}
endfunction
" to make the test pass.
call setline(1, ['a', 'b', 'c', 'd'])
else
- let g:ale_fixers.testft = [{buffer, lines -> lines + ['d']}]
+ let g:ale_fixers.testft = [{buffer, done, lines -> lines + ['d']}]
ALEFix
endif
\ ' bar,',
\ '))',
\ ],
- \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
+ \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), v:null, [
\ 'def foo():',
\ ' some_variable = this_is_a_longer_function(first_argument, second_argument, third_with_function_call(foo, bar))',
\ ])
\ ' a_third_long_word,',
\ ')'
\ ],
- \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
+ \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), v:null, [
\ 'x = this_line_is_between_79_and_90_characters(first, second, third, fourth, fifth)',
\ 'y = this_line_is_longer_than_90_characters(much_longer_word, another_longer_word, a_third_long_word)',
\ ])
\ ' bar,',
\ '))',
\ ],
- \ ale#fixers#generic#TrimWhitespace(bufnr(''), [
- \ 'def foo():',
- \ ' some_variable = this_is_a_longer_function(',
- \ 'first_argument,',
- \ ' second_argument,',
- \ ' third_with_function_call(',
- \ 'foo,',
- \ ' bar,',
- \ '))',
+ \ ale#fixers#generic#TrimWhitespace(bufnr(''), v:null, [
+ \ 'def foo():',
+ \ ' some_variable = this_is_a_longer_function(',
+ \ 'first_argument,',
+ \ ' second_argument,',
+ \ ' third_with_function_call(',
+ \ 'foo,',
+ \ ' bar,',
+ \ '))',
\ ])
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
endfunction
- function AddLine(buffer, lines) abort
+ function AddLine(buffer, done, lines) abort
return a:lines + ['x']
endfunction