]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/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 / handlers / xo.vim
1 call ale#Set('javascript_xo_executable', 'xo')
2 call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
3 call ale#Set('javascript_xo_options', '')
4
5 call ale#Set('typescript_xo_executable', 'xo')
6 call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
7 call ale#Set('typescript_xo_options', '')
8
9 function! ale#handlers#xo#GetExecutable(buffer) abort
10     let l:type = ale#handlers#xo#GetType(a:buffer)
11
12     return ale#path#FindExecutable(a:buffer, l:type . '_xo', [
13     \   'node_modules/xo/cli.js',
14     \   'node_modules/.bin/xo',
15     \])
16 endfunction
17
18 function! ale#handlers#xo#GetLintCommand(buffer) abort
19     return ale#Escape(ale#handlers#xo#GetExecutable(a:buffer))
20     \   . ale#Pad(ale#handlers#xo#GetOptions(a:buffer))
21     \   . ' --reporter json --stdin --stdin-filename %s'
22 endfunction
23
24 function! ale#handlers#xo#GetOptions(buffer) abort
25     let l:type = ale#handlers#xo#GetType(a:buffer)
26
27     return ale#Var(a:buffer, l:type . '_xo_options')
28 endfunction
29
30 " xo uses eslint and the output format is the same
31 function! ale#handlers#xo#HandleJSON(buffer, lines) abort
32     return ale#handlers#eslint#HandleJSON(a:buffer, a:lines)
33 endfunction
34
35 function! ale#handlers#xo#GetType(buffer) abort
36     let l:filetype = getbufvar(a:buffer, '&filetype')
37     let l:type = 'javascript'
38
39     if l:filetype =~# 'typescript'
40         let l:type = 'typescript'
41     endif
42
43     return l:type
44 endfunction