diff options
author | Magnus Ottenklinger <evnu@posteo.de> | 2017-08-23 09:03:13 +0200 |
---|---|---|
committer | Colby Dehart <colbydehart@gmail.com> | 2018-05-30 10:38:14 -0400 |
commit | 801c12a8813deb6ab20107fe8de979b86297b536 (patch) | |
tree | 33f64f89169e35e1c9ef13c348351f46c8f340ef /ale_linters/elixir | |
parent | 3014d853250d634803d6a3d620b898338b027e02 (diff) | |
download | ale-801c12a8813deb6ab20107fe8de979b86297b536.zip |
Add mix linter for elixir
Diffstat (limited to 'ale_linters/elixir')
-rw-r--r-- | ale_linters/elixir/mix.vim | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ale_linters/elixir/mix.vim b/ale_linters/elixir/mix.vim new file mode 100644 index 00000000..41cd18a0 --- /dev/null +++ b/ale_linters/elixir/mix.vim @@ -0,0 +1,42 @@ +" Author: evnu - https://github.com/evnu +" Author: colbydehart - https://github.com/colbydehart + +function! ale_linters#elixir#mix#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " Error format + " ** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4 + " + " TODO: Warning format + " warning: variable "foobar" does not exist and is being expanded to "foobar()", please use parentheses to remove the ambiguity or change the variable name + + let l:pattern = '\v\(([^\)]+Error)\) ([^:]+):([^:]+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = 'E' + let l:text = l:match[4] + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[3] + 0, + \ 'col': 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#elixir#mix#Command(buffer) abort + let l:project_dir = fnamemodify(ale#path#FindNearestFile(a:buffer, 'mix.exs'), ':h') + return 'cd ' . l:project_dir . ' && mix compile %s' +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'mix', +\ 'executable': 'mix', +\ 'command_callback': 'ale_linters#elixir#mix#Command', +\ 'callback': 'ale_linters#elixir#mix#Handle', +\}) |