2017-02-09 18:54:49 +00:00
|
|
|
" Author: Daniel Lupu <lupu.daniel.f@gmail.com>
|
|
|
|
" Description: xo for JavaScript files
|
|
|
|
|
|
|
|
let g:ale_javascript_xo_executable =
|
|
|
|
\ get(g:, 'ale_javascript_xo_executable', 'xo')
|
|
|
|
|
|
|
|
let g:ale_javascript_xo_options =
|
|
|
|
\ get(g:, 'ale_javascript_xo_options', '')
|
|
|
|
|
|
|
|
let g:ale_javascript_xo_use_global =
|
|
|
|
\ get(g:, 'ale_javascript_xo_use_global', 0)
|
|
|
|
|
|
|
|
function! ale_linters#javascript#xo#GetExecutable(buffer) abort
|
2017-04-27 22:01:01 +00:00
|
|
|
if ale#Var(a:buffer, 'javascript_xo_use_global')
|
|
|
|
return ale#Var(a:buffer, 'javascript_xo_executable')
|
2017-02-09 18:54:49 +00:00
|
|
|
endif
|
|
|
|
|
2017-04-17 22:29:02 +00:00
|
|
|
return ale#path#ResolveLocalPath(
|
2017-02-09 18:54:49 +00:00
|
|
|
\ a:buffer,
|
|
|
|
\ 'node_modules/.bin/xo',
|
2017-04-27 22:01:01 +00:00
|
|
|
\ ale#Var(a:buffer, 'javascript_xo_executable')
|
2017-02-09 18:54:49 +00:00
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#javascript#xo#GetCommand(buffer) abort
|
2017-05-12 08:20:16 +00:00
|
|
|
return ale#Escape(ale_linters#javascript#xo#GetExecutable(a:buffer))
|
2017-04-27 22:01:01 +00:00
|
|
|
\ . ' ' . ale#Var(a:buffer, 'javascript_xo_options')
|
2017-02-09 18:54:49 +00:00
|
|
|
\ . ' --reporter unix --stdin --stdin-filename %s'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#javascript#xo#Handle(buffer, lines) abort
|
|
|
|
" xo uses eslint and the output format is the same
|
|
|
|
return ale_linters#javascript#eslint#Handle(a:buffer, a:lines)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('javascript', {
|
|
|
|
\ 'name': 'xo',
|
|
|
|
\ 'executable_callback': 'ale_linters#javascript#xo#GetExecutable',
|
|
|
|
\ 'command_callback': 'ale_linters#javascript#xo#GetCommand',
|
|
|
|
\ 'callback': 'ale_linters#javascript#xo#Handle',
|
|
|
|
\})
|