Fix #315 Implement the read_buffer option

This commit is contained in:
w0rp
2017-02-09 23:32:57 +00:00
parent 9f8c76b5b9
commit 5de445c041
6 changed files with 262 additions and 29 deletions

View File

@@ -33,6 +33,10 @@ function! s:IsCallback(value) abort
return type(a:value) == type('') || type(a:value) == type(function('type'))
endfunction
function! s:IsBoolean(value) abort
return type(a:value) == type(0) && (a:value == 0 || a:value == 1)
endfunction
function! ale#linter#PreProcess(linter) abort
if type(a:linter) != type({})
throw 'The linter object must be a Dictionary'
@@ -95,6 +99,10 @@ function! ale#linter#PreProcess(linter) abort
endif
endif
if has_key(l:link, 'read_buffer') && !s:IsBoolean(l:link.read_buffer)
throw l:err_prefix . 'value for `read_buffer` must be `0` or `1`'
endif
let l:link_index += 1
endfor
elseif has_key(a:linter, 'command_callback')
@@ -130,6 +138,13 @@ function! ale#linter#PreProcess(linter) abort
throw "`output_stream` must be 'stdout', 'stderr', or 'both'"
endif
" An option indicating that the buffer should be read.
let l:obj.read_buffer = get(a:linter, 'read_buffer', 1)
if !s:IsBoolean(l:obj.read_buffer)
throw '`read_buffer` must be `0` or `1`'
endif
return l:obj
endfunction