Last active
August 29, 2015 14:24
-
-
Save marcotrosi/c6af19db33d9af20880b to your computer and use it in GitHub Desktop.
Vim - signs for static code analyzer like splint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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