Skip to content

Instantly share code, notes, and snippets.

@marcotrosi
Last active August 29, 2015 14:24
Show Gist options
  • Save marcotrosi/c6af19db33d9af20880b to your computer and use it in GitHub Desktop.
Save marcotrosi/c6af19db33d9af20880b to your computer and use it in GitHub Desktop.
Vim - signs for static code analyzer like splint
hi org guifg=#FD971F guibg=#232526 gui=bold
sign define Warn text=! texthl=org
function! LintSign()
let Messages_l = []
let SignIDCnt = 0
" capture splint output as list
let LintOutput_l=systemlist("splint *.c")
" remove all previously placed signs
sign unplace *
" iterate through list
for line in LintOutput_l
" find the message lines and capture filename and linenumber (here for standard gcc format)
let Match_l = matchlist(line, '^\(.\{-}\):\(\d\+\):')
if len(Match_l) != 0 " if match
" add matching line to list
call add(Messages_l, line)
" increment the sign ID counter
let SignIDCnt = SignIDCnt + 1
" place the sign
exe "sign place " . SignIDCnt . " line=" . Match_l[2] . " name=Warn file=" . Match_l[1]
endif
endfor
" save messages in file for creating balloon boxes later
call writefile(Messages_l, "project.lnt")
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment