2017-07-18 22:57:33 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: Check Dart files with dartanalyzer
|
|
|
|
|
|
|
|
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer')
|
|
|
|
|
|
|
|
function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
|
|
|
|
let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
|
|
|
|
|
2018-08-02 22:44:12 +00:00
|
|
|
return '%e'
|
2017-07-18 22:57:33 +00:00
|
|
|
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
|
2017-10-26 22:31:07 +00:00
|
|
|
\ . ' %s'
|
2017-07-18 22:57:33 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
|
|
|
|
let l:pattern = '\v^ ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$'
|
|
|
|
let l:output = []
|
|
|
|
|
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
call add(l:output, {
|
2017-08-08 07:39:13 +00:00
|
|
|
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
|
2017-07-18 22:57:33 +00:00
|
|
|
\ 'text': l:match[6] . ': ' . l:match[2],
|
|
|
|
\ 'lnum': str2nr(l:match[4]),
|
|
|
|
\ 'col': str2nr(l:match[5]),
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('dart', {
|
|
|
|
\ 'name': 'dartanalyzer',
|
2018-08-02 22:44:12 +00:00
|
|
|
\ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'),
|
2017-07-18 22:57:33 +00:00
|
|
|
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
|
|
|
|
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
|
2017-10-26 22:31:07 +00:00
|
|
|
\ 'lint_file': 1,
|
2017-07-18 22:57:33 +00:00
|
|
|
\})
|