2018-03-31 10:55:20 -04:00
|
|
|
" Author: Jeff Willette <jrwillette88@gmail.com>
|
|
|
|
" Description: Integration of importjs with ALE.
|
|
|
|
|
2018-08-25 12:13:42 -04:00
|
|
|
call ale#Set('javascript_importjs_executable', 'importjs')
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
function! ale#fixers#importjs#ProcessOutput(buffer, output) abort
|
|
|
|
let l:result = ale#util#FuzzyJSONDecode(a:output, [])
|
2018-09-24 20:40:17 -04:00
|
|
|
|
2018-03-31 10:55:20 -04:00
|
|
|
return split(get(l:result, 'fileContent', ''), "\n")
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#fixers#importjs#Fix(buffer) abort
|
2018-08-25 12:13:42 -04:00
|
|
|
let l:executable = ale#Var(a:buffer, 'javascript_importjs_executable')
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
if !executable(l:executable)
|
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
return {
|
|
|
|
\ 'command': ale#Escape(l:executable)
|
|
|
|
\ . ' fix'
|
|
|
|
\ . ' %s',
|
|
|
|
\ 'process_with': 'ale#fixers#importjs#ProcessOutput',
|
|
|
|
\}
|
|
|
|
endfunction
|