diff options
author | Bjorn Neergaard <bjorn@neersighted.com> | 2018-11-29 14:57:35 -0700 |
---|---|---|
committer | Bjorn Neergaard <bjorn@neersighted.com> | 2018-11-29 14:57:35 -0700 |
commit | d2b0ae8108b2ee395d4eb43c49d68b322a023a30 (patch) | |
tree | bb8145e69bf1bcb8968b29cb1a68c47ceb83674d /ale_linters/elixir | |
parent | ef641dda80f45cb979bc93c2513c6e10cbd8e42a (diff) | |
parent | 0a384a49d371838903d8401c5358ec60f3f4266d (diff) | |
download | ale-d2b0ae8108b2ee395d4eb43c49d68b322a023a30.zip |
Merge branch 'master' into sridhars
Diffstat (limited to 'ale_linters/elixir')
-rw-r--r-- | ale_linters/elixir/credo.vim | 23 | ||||
-rw-r--r-- | ale_linters/elixir/dialyxir.vim | 9 | ||||
-rw-r--r-- | ale_linters/elixir/dogma.vim | 9 | ||||
-rw-r--r-- | ale_linters/elixir/elixir_ls.vim | 21 | ||||
-rw-r--r-- | ale_linters/elixir/mix.vim | 15 |
5 files changed, 59 insertions, 18 deletions
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim index af2ff48a..d778471c 100644 --- a/ale_linters/elixir/credo.vim +++ b/ale_linters/elixir/credo.vim @@ -11,10 +11,18 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort let l:type = l:match[3] let l:text = l:match[4] - if l:type is# 'C' - let l:type = 'E' - elseif l:type is# 'R' + " Refactoring opportunities + if l:type is# 'F' + let l:type = 'W' + " Consistency + elseif l:type is# 'C' let l:type = 'W' + " Software Design + elseif l:type is# 'D' + let l:type = 'I' + " Code Readability + elseif l:type is# 'R' + let l:type = 'I' endif call add(l:output, { @@ -29,9 +37,16 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#elixir#credo#GetCommand(buffer) abort + let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) + + return ale#path#CdString(l:project_root) + \ . ' mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s' +endfunction + call ale#linter#Define('elixir', { \ 'name': 'credo', \ 'executable': 'mix', -\ 'command': 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s', +\ 'command_callback': 'ale_linters#elixir#credo#GetCommand', \ 'callback': 'ale_linters#elixir#credo#Handle', \}) diff --git a/ale_linters/elixir/dialyxir.vim b/ale_linters/elixir/dialyxir.vim index bba0ae14..d28d3c70 100644 --- a/ale_linters/elixir/dialyxir.vim +++ b/ale_linters/elixir/dialyxir.vim @@ -25,10 +25,17 @@ function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#elixir#dialyxir#GetCommand(buffer) abort + let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) + + return ale#path#CdString(l:project_root) + \ . ' mix help dialyzer && mix dialyzer' +endfunction + call ale#linter#Define('elixir', { \ 'name': 'dialyxir', \ 'executable': 'mix', -\ 'command': 'mix help dialyzer && mix dialyzer', +\ 'command_callback': 'ale_linters#elixir#dialyxir#GetCommand', \ 'callback': 'ale_linters#elixir#dialyxir#Handle', \}) diff --git a/ale_linters/elixir/dogma.vim b/ale_linters/elixir/dogma.vim index 71cf4f4c..dcfb6f28 100644 --- a/ale_linters/elixir/dogma.vim +++ b/ale_linters/elixir/dogma.vim @@ -29,10 +29,17 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#elixir#dogma#GetCommand(buffer) abort + let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) + + return ale#path#CdString(l:project_root) + \ . ' mix help dogma && mix dogma %s --format=flycheck' +endfunction + call ale#linter#Define('elixir', { \ 'name': 'dogma', \ 'executable': 'mix', -\ 'command': 'mix help dogma && mix dogma %s --format=flycheck', +\ 'command_callback': 'ale_linters#elixir#dogma#GetCommand', \ 'lint_file': 1, \ 'callback': 'ale_linters#elixir#dogma#Handle', \}) diff --git a/ale_linters/elixir/elixir_ls.vim b/ale_linters/elixir/elixir_ls.vim new file mode 100644 index 00000000..3b299ec6 --- /dev/null +++ b/ale_linters/elixir/elixir_ls.vim @@ -0,0 +1,21 @@ +" Author: Jon Parise <jon@indelible.org> +" Description: ElixirLS integration (https://github.com/JakeBecker/elixir-ls) + +call ale#Set('elixir_elixir_ls_release', 'elixir-ls') +call ale#Set('elixir_elixir_ls_config', {}) + +function! ale_linters#elixir#elixir_ls#GetExecutable(buffer) abort + let l:dir = ale#path#Simplify(ale#Var(a:buffer, 'elixir_elixir_ls_release')) + let l:cmd = ale#Has('win32') ? '\language_server.bat' : '/language_server.sh' + + return l:dir . l:cmd +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'elixir-ls', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#elixir#elixir_ls#GetExecutable', +\ 'command_callback': 'ale_linters#elixir#elixir_ls#GetExecutable', +\ 'project_root_callback': 'ale#handlers#elixir#FindMixUmbrellaRoot', +\ 'lsp_config_callback': ale#VarFunc('elixir_elixir_ls_config'), +\}) diff --git a/ale_linters/elixir/mix.vim b/ale_linters/elixir/mix.vim index 1a95e37f..dc3c1818 100644 --- a/ale_linters/elixir/mix.vim +++ b/ale_linters/elixir/mix.vim @@ -10,7 +10,6 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort " " 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 = [] @@ -30,16 +29,8 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#elixir#mix#FindProjectRoot(buffer) abort - let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs') - if !empty(l:mix_file) - return fnamemodify(l:mix_file, ':p:h') - endif - return '.' -endfunction - function! ale_linters#elixir#mix#GetCommand(buffer) abort - let l:project_root = ale_linters#elixir#mix#FindProjectRoot(a:buffer) + let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) let l:temp_dir = ale#engine#CreateDirectory(a:buffer) @@ -48,8 +39,8 @@ function! ale_linters#elixir#mix#GetCommand(buffer) abort \ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) return ale#path#CdString(l:project_root) - \ . l:mix_build_path - \ . ' mix compile %s' + \ . l:mix_build_path + \ . ' mix compile %s' endfunction call ale#linter#Define('elixir', { |