1
0
Fork 0
mirror of synced 2024-11-16 14:05:34 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/elixir/mix.vim

53 lines
1.6 KiB
VimL
Raw Normal View History

2018-07-04 06:53:25 -04:00
" Author: evnu - https://github.com/evnu
" Author: colbydehart - https://github.com/colbydehart
" Description: Mix compile checking for Elixir files
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#GetCommand(buffer) abort
2018-11-01 06:03:42 -04:00
let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
2018-07-04 06:53:25 -04:00
2019-03-08 06:04:56 -05:00
let l:temp_dir = ale#command#CreateDirectory(a:buffer)
2018-07-04 06:53:25 -04:00
let l:mix_build_path = has('win32')
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&'
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir)
return ale#path#CdString(l:project_root)
2018-11-01 06:03:42 -04:00
\ . l:mix_build_path
\ . ' mix compile %s'
2018-07-04 06:53:25 -04:00
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'mix',
\ 'executable': 'mix',
2019-03-08 06:04:56 -05:00
\ 'command': function('ale_linters#elixir#mix#GetCommand'),
2018-07-04 06:53:25 -04:00
\ 'callback': 'ale_linters#elixir#mix#Handle',
\ 'lint_file': 1,
\})