]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/fixers/xo.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / fixers / xo.vim
1 " Author: Albert Marquez - https://github.com/a-marquez
2 " Description: Fixing files with XO.
3
4 function! ale#fixers#xo#Fix(buffer) abort
5     let l:executable = ale#handlers#xo#GetExecutable(a:buffer)
6     let l:options = ale#handlers#xo#GetOptions(a:buffer)
7
8     return ale#semver#RunWithVersionCheck(
9     \   a:buffer,
10     \   l:executable,
11     \   '%e --version',
12     \   {b, v -> ale#fixers#xo#ApplyFixForVersion(b, v, l:executable, l:options)}
13     \)
14 endfunction
15
16 function! ale#fixers#xo#ApplyFixForVersion(buffer, version, executable, options) abort
17     let l:executable = ale#node#Executable(a:buffer, a:executable)
18     let l:options = ale#Pad(a:options)
19
20     " 0.30.0 is the first version with a working --stdin --fix
21     if ale#semver#GTE(a:version, [0, 30, 0])
22         return {
23         \   'command': l:executable
24         \       . ' --stdin --stdin-filename %s'
25         \       . ' --fix'
26         \       . l:options,
27         \}
28     endif
29
30     return {
31     \   'command': l:executable
32     \       . ' --fix %t'
33     \       . l:options,
34     \   'read_temporary_file': 1,
35     \}
36 endfunction