Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: add an option to ignore diagnostics warnings #3050

Merged
merged 1 commit into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ function! go#config#DiagnosticsEnabled() abort
return get(g:, 'go_diagnostics_enabled', 0)
endfunction

function! go#config#DiagnosticsIgnoreWarnings() abort
return get(g:, 'go_diagnostics_ignore_warnings', 0)
endfunction

function! go#config#GoplsOptions() abort
return get(g:, 'go_gopls_options', ['-remote=auto'])
endfunction
Expand Down
19 changes: 12 additions & 7 deletions autoload/go/lint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ function! go#lint#Diagnostics(bang, ...) abort

let l:listtype = go#list#Type("GoDiagnostics")

if len(l:messages) == 0
" Parse and populate the quickfix list
let l:winid = win_getid(winnr())
call go#list#ParseFormat(l:listtype, l:errformat, l:messages, 'GoDiagnostics', 0)

let l:errors = go#list#Get(l:listtype)

if len(l:errors) == 0
call go#list#Clean(l:listtype)
call go#util#EchoSuccess('[diagnostics] PASS')
else
" Parse and populate the quickfix list
let l:winid = win_getid(winnr())
call go#list#ParseFormat(l:listtype, l:errformat, l:messages, 'GoDiagnostics', 0)

let errors = go#list#Get(l:listtype)
call go#list#Window(l:listtype, len(errors))

if a:bang
Expand Down Expand Up @@ -467,7 +468,11 @@ function! s:errorformat(metalinter) abort
elseif a:metalinter == 'staticcheck'
return '%f:%l:%c:\ %m'
elseif a:metalinter == 'gopls'
return '%f:%l:%c:%t:\ %m,%f:%l:%c::\ %m,%f:%l::%t:\ %m'
let l:efm = ''
if go#config#DiagnosticsIgnoreWarnings()
let l:efm = '%-G%f:%l:%c:W:\ %m,%-G%f:%l::W:\ %m,'
endif
return l:efm . '%f:%l:%c:%t:\ %m,%f:%l:%c::\ %m,%f:%l::%t:\ %m'
endif
endfunction

Expand Down
4 changes: 3 additions & 1 deletion autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,9 @@ function! s:highlightMatches(errorMatches, warningMatches) abort
call go#util#ClearHighlights('goDiagnosticWarning')
if go#config#HighlightDiagnosticWarnings()
let b:go_diagnostic_matches.warnings = copy(a:warningMatches)
call go#util#HighlightPositions('goDiagnosticWarning', a:warningMatches)
if !go#config#DiagnosticsIgnoreWarnings()
call go#util#HighlightPositions('goDiagnosticWarning', a:warningMatches)
endif
endif
endif

Expand Down
8 changes: 8 additions & 0 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,14 @@ By default it is disabled.
>
let g:go_diagnostics_enabled = 0
<
*'g:go_diagnostics_ignore_warnings'*

Specifies whether warnings from `gopls` diagnostics are ignored.

By default it is disabled.
>
let g:go_diagnostics_ignore_warnings = 0
<

*'g:go_template_autocreate'*

Expand Down