Fix parsing of cl error messages in vim so that it differentiates between an error and warning!

This commit is contained in:
Michael Campagnaro 2022-11-28 23:39:20 -05:00
parent 06f155f3f7
commit 221985eca2

55
vimrc
View File

@ -1101,23 +1101,60 @@ augroup END
" AsyncRun status line
let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
" Display error highlighting in source after running GCC with AsyncRun
" NOTE: error results can be cleared with <leader>cr or by hiding the build
" result window.
" "make" value is needed for asyncrun to work with the errormarker plugin
" https://github.com/skywind3000/asyncrun.vim/wiki/FAQ#can-asyncrunvim-trigger-an-autocommand-quickfixcmdpost-to-get-some-plugin-like-errormaker-processing-the-content-in-quickfix-
let g:asyncrun_auto = "make"
" Error and warning gutter characters.
let errormarker_errortext = "E"
let errormarker_warningtext = "W"
" Thanks to https://forums.handmadehero.org/index.php/forum?view=topic&catid=4&id=704#3982
" for the error message formats
"
" Microsoft MSBuild errors
set errorformat+=\\\ %#%f(%l\\\,%c):\ %m
" Error and warning gutter character colors. See color file for the group definition.
let errormarker_errortextgroup = "ErrorMsg"
let errormarker_warningtextgroup = "Notices"
"""""""""""""""""""""""""
" Custom error formats
"""""""""""""""""""""""""
" @note: You can debug the error parsing by running :ShowErrorEntries
" This will print the valid entries. You'll know parsing is correct when the
" entries have a type, line num, error message, etc.
function! s:ShowErrorEntries()
" Prints out valid quickfix errors.
redraw!
for l:d in getqflist()
if l:d.valid == 1
echomsg l:d
endif
endfor
endfunction
command -nargs=0 ShowErrorEntries call s:ShowErrorEntries()
" Microsoft compiler: cl.exe
set errorformat+=\\\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
"
" Z:\path\main.cpp(2808): error C2220: the following warning is treated as an error
set errorformat=\\\ %#%f(%l):\ %#%t%[A-z]%#\ %[A-z]%#%n:\ %m
" Microsoft MSBuild errors
"
" @note I got this off the Internet and haven't tested it yet.
"
" Z:\path\main.cpp(2808): error C2220: the following warning is treated as an error
set errorformat+=\\\ %#%f(%l\\,%c):\ %m
" Microsoft HLSL compiler: fxc.exe
"
" @note I got this off the Internet and haven't tested it yet.
" @todo Add an example
set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m
"""""""""""""""""""""""""
" Build functions
"""""""""""""""""""""""""
function! HideBuildResultsAndClearErrors()
RemoveErrorMarkers
call asyncrun#quickfix_toggle(g:quickfix_pane_height, 0)