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 | |
parent | 3014d853250d634803d6a3d620b898338b027e02 (diff) | |
download | ale-801c12a8813deb6ab20107fe8de979b86297b536.zip |
Add mix linter for elixir
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | ale_linters/elixir/mix.vim | 42 | ||||
-rw-r--r-- | doc/ale.txt | 2 |
3 files changed, 44 insertions, 2 deletions
@@ -108,7 +108,7 @@ formatting. | Dafny | [dafny](https://rise4fun.com/Dafny) !! | | Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) !!, [language_server](https://github.com/natebosch/dart_language_server) | | Dockerfile | [hadolint](https://github.com/hadolint/hadolint) | -| Elixir | [credo](https://github.com/rrrene/credo), [dialyxir](https://github.com/jeremyjh/dialyxir), [dogma](https://github.com/lpil/dogma) !!| +| Elixir | [credo](https://github.com/rrrene/credo), [dialyxir](https://github.com/jeremyjh/dialyxir), [dogma](https://github.com/lpil/dogma), [mix](https://hexdocs.pm/mix/Mix.html) !!| | Elm | [elm-format](https://github.com/avh4/elm-format), [elm-make](https://github.com/elm-lang/elm-make) | | Erb | [erb](https://apidock.com/ruby/ERB), [erubi](https://github.com/jeremyevans/erubi), [erubis](https://github.com/kwatch/erubis) | | Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) | 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', +\}) diff --git a/doc/ale.txt b/doc/ale.txt index 0bf1c849..24a41106 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -332,7 +332,7 @@ Notes: * Dafny: `dafny`!! * Dart: `dartanalyzer`!!, `language_server` * Dockerfile: `hadolint` -* Elixir: `credo`, `dialyxir`, `dogma`!! +* Elixir: `credo`, `dialyxir`, `dogma`, `mix`!! * Elm: `elm-format, elm-make` * Erb: `erb`, `erubi`, `erubis` * Erlang: `erlc`, `SyntaxErl` |