Merge pull request #1552 from a-marquez/master

Add XO fixer
This commit is contained in:
w0rp 2018-05-08 17:53:12 +01:00 committed by GitHub
commit 9023987fe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -190,6 +190,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['perl'],
\ 'description': 'Fix Perl files with perltidy.',
\ },
\ 'xo': {
\ 'function': 'ale#fixers#xo#Fix',
\ 'suggested_filetypes': ['javascript'],
\ 'description': 'Fix JavaScript files using xo --fix.',
\ },
\}
" Reset the function registry to the default entries.

View File

@ -0,0 +1,23 @@
" Author: Albert Marquez - https://github.com/a-marquez
" Description: Fixing files with XO.
call ale#Set('javascript_xo_executable', 'xo')
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_xo_options', '')
function! ale#fixers#xo#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
\ 'node_modules/xo/cli.js',
\ 'node_modules/.bin/xo',
\])
endfunction
function! ale#fixers#xo#Fix(buffer) abort
let l:executable = ale#fixers#xo#GetExecutable(a:buffer)
return {
\ 'command': ale#node#Executable(a:buffer, l:executable)
\ . ' --fix %t',
\ 'read_temporary_file': 1,
\}
endfunction