Skip to content

Commit 2f85421

Browse files
committed
Fix lnum and col for Vim to recognize it as an error
1 parent fa7770c commit 2f85421

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

autoload/ghcmod.vim

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ function! ghcmod#detect_module()"{{{
153153
return 'Main'
154154
endfunction"}}}
155155

156+
function! s:fix_qf_lnum_col(qf)"{{{
157+
" ghc-mod reports dummy error message with lnum=0 and col=0.
158+
" This is not suitable for Vim, so tweak them.
159+
for l:key in ['lnum', 'col']
160+
if get(a:qf, l:key, -1) == 0
161+
let a:qf[l:key] = 1
162+
endif
163+
endfor
164+
endfunction"}}}
165+
156166
function! ghcmod#parse_make(lines, basedir)"{{{
157167
" `ghc-mod check` and `ghc-mod lint` produces <NUL> characters but Vim cannot
158168
" treat them correctly. Vim converts <NUL> characters to <NL> in readfile().
@@ -187,10 +197,8 @@ function! ghcmod#parse_make(lines, basedir)"{{{
187197
call add(l:qflist, {'text': l:text})
188198
endfor
189199
else
190-
let l:qf.filename = ''
191-
let l:errortext = join(a:lines, "\n")
192-
let l:qf.bufnr = 0
193200
let l:qf.type = 'E'
201+
call s:fix_qf_lnum_col(l:qf)
194202
let l:qf.text = 'parse error in ghcmod! Could not parse the following ghc-mod output:'
195203
call add(l:qflist, l:qf)
196204
for l:text in a:lines
@@ -369,6 +377,7 @@ function! ghcmod#expand()"{{{
369377
if has_key(l:qf, 'filename')
370378
let l:qf.filename = s:join_path(l:dir, l:qf.filename)
371379
endif
380+
call s:fix_qf_lnum_col(l:qf)
372381
call add(l:qflist, l:qf)
373382
endfor
374383
return l:qflist

0 commit comments

Comments
 (0)