summaryrefslogtreecommitdiff
path: root/ale_linters/elm/make.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/elm/make.vim')
-rw-r--r--ale_linters/elm/make.vim156
1 files changed, 100 insertions, 56 deletions
diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim
index 5f9334da..05907acf 100644
--- a/ale_linters/elm/make.vim
+++ b/ale_linters/elm/make.vim
@@ -16,62 +16,12 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
for l:line in a:lines
if l:line[0] is# '{'
- let l:report = json_decode(l:line)
-
- if l:report.type is? 'error'
- " General problem
- let l:details = ale_linters#elm#make#ParseMessage(l:report.message)
-
- if empty(l:report.path)
- let l:report.path = 'Elm.Kernel'
- endif
-
- if ale_linters#elm#make#FileIsBuffer(l:report.path)
- call add(l:output, {
- \ 'lnum': 1,
- \ 'type': 'E',
- \ 'text': l:details,
- \})
- else
- call add(l:output, {
- \ 'lnum': 1,
- \ 'type': 'E',
- \ 'text': l:report.path .' - '. l:details,
- \ 'detail': l:report.path ." ----------\n\n". l:details,
- \})
- endif
- else
- " Compilation errors
- for l:error in l:report.errors
- let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path)
-
- for l:problem in l:error.problems
- let l:details = ale_linters#elm#make#ParseMessage(l:problem.message)
-
- if l:file_is_buffer
- " Buffer module has problems
- call add(l:output, {
- \ 'lnum': l:problem.region.start.line,
- \ 'col': l:problem.region.start.column,
- \ 'end_lnum': l:problem.region.end.line,
- \ 'end_col': l:problem.region.end.column,
- \ 'type': 'E',
- \ 'text': l:details,
- \})
- else
- " Imported module has problems
- let l:location = l:error.path .':'. l:problem.region.start.line
- call add(l:output, {
- \ 'lnum': 1,
- \ 'type': 'E',
- \ 'text': l:location .' - '. l:details,
- \ 'detail': l:location ." ----------\n\n". l:details,
- \})
- endif
- endfor
- endfor
- endif
- else
+ " Elm 0.19
+ call ale_linters#elm#make#HandleElm019Line(l:line, l:output)
+ elseif l:line[0] is# '['
+ " Elm 0.18
+ call ale_linters#elm#make#HandleElm018Line(l:line, l:output)
+ elseif l:line isnot# 'Successfully generated /dev/null'
call add(l:unparsed_lines, l:line)
endif
endfor
@@ -88,6 +38,95 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
return l:output
endfunction
+function! ale_linters#elm#make#HandleElm019Line(line, output) abort
+ let l:report = json_decode(a:line)
+
+ if l:report.type is? 'error'
+ " General problem
+ let l:details = ale_linters#elm#make#ParseMessage(l:report.message)
+
+ if empty(l:report.path)
+ let l:report.path = 'Elm'
+ endif
+
+ if ale_linters#elm#make#FileIsBuffer(l:report.path)
+ call add(a:output, {
+ \ 'lnum': 1,
+ \ 'type': 'E',
+ \ 'text': l:details,
+ \})
+ else
+ call add(a:output, {
+ \ 'lnum': 1,
+ \ 'type': 'E',
+ \ 'text': l:report.path .' - '. l:details,
+ \ 'detail': l:report.path ." ----------\n\n". l:details,
+ \})
+ endif
+ else
+ " Compilation errors
+ for l:error in l:report.errors
+ let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path)
+
+ for l:problem in l:error.problems
+ let l:details = ale_linters#elm#make#ParseMessage(l:problem.message)
+
+ if l:file_is_buffer
+ " Buffer module has problems
+ call add(a:output, {
+ \ 'lnum': l:problem.region.start.line,
+ \ 'col': l:problem.region.start.column,
+ \ 'end_lnum': l:problem.region.end.line,
+ \ 'end_col': l:problem.region.end.column,
+ \ 'type': 'E',
+ \ 'text': l:details,
+ \})
+ else
+ " Imported module has problems
+ let l:location = l:error.path .':'. l:problem.region.start.line
+ call add(a:output, {
+ \ 'lnum': 1,
+ \ 'type': 'E',
+ \ 'text': l:location .' - '. l:details,
+ \ 'detail': l:location ." ----------\n\n". l:details,
+ \})
+ endif
+ endfor
+ endfor
+ endif
+endfunction
+
+function! ale_linters#elm#make#HandleElm018Line(line, output) abort
+ let l:errors = json_decode(a:line)
+
+ for l:error in l:errors
+ let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.file)
+
+ if l:file_is_buffer
+ " Current buffer has problems
+ call add(a:output, {
+ \ 'lnum': l:error.region.start.line,
+ \ 'col': l:error.region.start.column,
+ \ 'end_lnum': l:error.region.end.line,
+ \ 'end_col': l:error.region.end.column,
+ \ 'type': (l:error.type is? 'error') ? 'E' : 'W',
+ \ 'text': l:error.overview,
+ \ 'detail': l:error.overview . "\n\n" . l:error.details
+ \})
+ elseif l:error.type is? 'error'
+ " Imported module has errors
+ let l:location = l:error.file .':'. l:error.region.start.line
+
+ call add(a:output, {
+ \ 'lnum': 1,
+ \ 'type': 'E',
+ \ 'text': l:location .' - '. l:error.overview,
+ \ 'detail': l:location ." ----------\n\n". l:error.overview . "\n\n" . l:error.details
+ \})
+ endif
+ endfor
+endfunction
+
function! ale_linters#elm#make#FileIsBuffer(path) abort
let l:is_windows = has('win32')
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
@@ -118,6 +157,11 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
let l:elm_exe = ale_linters#elm#make#GetExecutable(a:buffer)
if empty(l:elm_json)
+ " Fallback to Elm 0.18
+ let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
+ endif
+
+ if empty(l:elm_json)
let l:dir_set_cmd = ''
else
let l:root_dir = fnamemodify(l:elm_json, ':p:h')