summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-05-08 17:53:12 +0100
committerGitHub <noreply@github.com>2018-05-08 17:53:12 +0100
commit9023987fe0a7916afbed173c9cdc8f82811d071e (patch)
treecc5f69636508e7d60b36459ff559dc193f211551 /autoload
parent726a768464d3e42869088599cf1bd049f7a751df (diff)
parent14dc05f36bc14ac9e5373103d69293b888e85145 (diff)
downloadale-9023987fe0a7916afbed173c9cdc8f82811d071e.zip
Merge pull request #1552 from a-marquez/master
Add XO fixer
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/xo.vim23
2 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 7e45e6ad..7b5fdb8e 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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.
diff --git a/autoload/ale/fixers/xo.vim b/autoload/ale/fixers/xo.vim
new file mode 100644
index 00000000..882350be
--- /dev/null
+++ b/autoload/ale/fixers/xo.vim
@@ -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