Skip to content

Commit

Permalink
Merge pull request #2810 from bhcleek/lint/preserve-errors
Browse files Browse the repository at this point in the history
lint: do not duplicate errors in quickfix on save
  • Loading branch information
bhcleek authored Apr 6, 2020
2 parents c074280 + cb1206b commit dab3d36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function! go#fmt#CleanErrors() abort
let l:list_title = getloclist(0, {'title': 1})
endif

if has_key(l:list_title, "title") && l:list_title['title'] == "Format"
if has_key(l:list_title, 'title') && (l:list_title['title'] == 'Format' || l:list_title['title'] == 'GoMetaLinterAutoSave')
call go#list#Clean(l:listtype)
endif
endfunction
Expand Down
18 changes: 10 additions & 8 deletions autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ function! go#lint#Gometa(bang, autosave, ...) abort
endif

if a:autosave
let l:listtype = go#list#Type("GoMetaLinterAutoSave")
let l:listtype = go#list#Type('GoMetaLinterAutoSave')
let l:for = 'GoMetaLinterAutoSave'
else
let l:listtype = go#list#Type("GoMetaLinter")
let l:listtype = go#list#Type('GoMetaLinter')
let l:for = 'GoMetaLinterAuto'
endif

if l:err == 0
Expand All @@ -100,7 +102,7 @@ function! go#lint#Gometa(bang, autosave, ...) abort
if a:autosave
call s:metalinterautosavecomplete(l:metalinter, fnamemodify(expand('%:p'), ":."), 0, 1, l:messages)
endif
call go#list#ParseFormat(l:listtype, errformat, l:messages, 'GoMetaLinter', s:preserveerrors(a:autosave, l:listtype))
call go#list#ParseFormat(l:listtype, errformat, l:messages, l:for, s:preserveerrors(a:autosave, l:listtype))

let errors = go#list#Get(l:listtype)
call go#list#Window(l:listtype, len(errors))
Expand Down Expand Up @@ -370,15 +372,15 @@ function! s:lint_job(metalinter, args, bang, autosave)
let l:opts = {
\ 'statustype': a:args.statustype,
\ 'errorformat': a:args.errformat,
\ 'for': "GoMetaLinter",
\ 'for': 'GoMetaLinter',
\ 'bang': a:bang,
\ }

if a:autosave
let l:opts.for = "GoMetaLinterAutoSave"
let l:opts.for = 'GoMetaLinterAutoSave'
" s:metalinterautosavecomplete is really only needed for golangci-lint
let l:opts.complete = funcref('s:metalinterautosavecomplete', [a:metalinter, expand('%:p:t')])
let l:opts.preserveerrors = function('s:preserveerrors')
let l:opts.preserveerrors = funcref('s:preserveerrors', [a:autosave])
endif

" autowrite is not enabled for jobs
Expand Down Expand Up @@ -449,8 +451,8 @@ function! s:errorformat(metalinter) abort

endfunction

function! s:preserveerrors(listtype) abort
return a:listtype == go#list#Type("GoFmt") && go#config#FmtAutosave() && isdirectory(expand('%:p:h'))
function! s:preserveerrors(autosave, listtype) abort
return a:autosave && a:listtype == go#list#Type("GoFmt") && go#config#FmtAutosave() && isdirectory(expand('%:p:h'))
endfunction

" restore Vi compatibility settings
Expand Down

0 comments on commit dab3d36

Please sign in to comment.