summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorghsang <66662835+ghsang@users.noreply.github.com>2021-07-25 13:48:12 +0900
committerGitHub <noreply@github.com>2021-07-25 13:48:12 +0900
commit73d32335fe0b9d723e19f098d3c263b01e17d234 (patch)
tree00939ac8aaf01fcfbd077e649e79aa12efc8822a /ale_linters
parent8c591996a83d623fb158fe090acbd89dabbfaf06 (diff)
downloadale-73d32335fe0b9d723e19f098d3c263b01e17d234.zip
Add support for `dart analyze` (#3825)
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/dart/dart_analyze.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/ale_linters/dart/dart_analyze.vim b/ale_linters/dart/dart_analyze.vim
new file mode 100644
index 00000000..a00162d8
--- /dev/null
+++ b/ale_linters/dart/dart_analyze.vim
@@ -0,0 +1,28 @@
+" Author: ghsang <gwonhyuksang@gmail.com>
+" Description: Check Dart files with dart analyze
+
+call ale#Set('dart_analyze_executable', 'dart')
+
+function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort
+ let l:pattern = '\v^ ([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'type': l:match[1] is# 'error' ? 'E' : 'W',
+ \ 'text': l:match[6] . ': ' . l:match[5],
+ \ 'lnum': str2nr(l:match[3]),
+ \ 'col': str2nr(l:match[4]),
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('dart', {
+\ 'name': 'dart_analyze',
+\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')},
+\ 'command': '%e analyze %s',
+\ 'callback': 'ale_linters#dart#dart_analyze#Handle',
+\ 'lint_file': 1,
+\})