]> git.madduck.net Git - etc/vim.git/blob - ale_linters/elixir/mix.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] / ale_linters / elixir / mix.vim
1 " Author: evnu - https://github.com/evnu
2 " Author: colbydehart - https://github.com/colbydehart
3 " Description: Mix compile checking for Elixir files
4
5 function! ale_linters#elixir#mix#Handle(buffer, lines) abort
6     " Matches patterns like the following:
7     "
8     " Error format
9     " ** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4
10     "
11     " TODO: Warning format
12     " warning: variable "foobar" does not exist and is being expanded to "foobar()", please use parentheses to remove the ambiguity or change the variable name
13     let l:pattern = '\v\(([^\)]+Error)\) ([^:]+):([^:]+): (.+)$'
14     let l:output = []
15
16     for l:match in ale#util#GetMatches(a:lines, l:pattern)
17         let l:type = 'E'
18         let l:text = l:match[4]
19
20         call add(l:output, {
21         \   'bufnr': a:buffer,
22         \   'lnum': l:match[3] + 0,
23         \   'col': 0,
24         \   'type': l:type,
25         \   'text': l:text,
26         \})
27     endfor
28
29     return l:output
30 endfunction
31
32 function! ale_linters#elixir#mix#GetCommand(buffer) abort
33     let l:temp_dir = ale#command#CreateDirectory(a:buffer)
34
35     return ale#Env('MIX_BUILD_PATH', l:temp_dir) . 'mix compile %s'
36 endfunction
37
38 call ale#linter#Define('elixir', {
39 \   'name': 'mix',
40 \   'executable': 'mix',
41 \   'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
42 \   'command': function('ale_linters#elixir#mix#GetCommand'),
43 \   'callback': 'ale_linters#elixir#mix#Handle',
44 \   'lint_file': 1,
45 \})