[haiku-development] vim script to detect haiku coding guidelines violations

  • From: PulkoMandy <pulkomandy@xxxxxxxxx>
  • To: Haiku dev <haiku-development@xxxxxxxxxxxxx>
  • Date: Wed, 12 Aug 2009 11:42:27 +0200

Here is a small script that will detect some guideline violations for
vim. I put it in my .vimrc and it highlight all the errors it can find
in all opened files.
It's not perfect yet, so I'd like to know if you made improvements on it :)

autocmd QuickFixCmdPost make cw

" autocmd that will set up the w:created variable (vim tip 1598)
autocmd VimEnter * autocmd WinEnter * let w:created=1

:fu FuncHaikuCheck()
        call matchadd('ErrorMsg', '\%>80v.\+', -1) " More than 80 chars on a 
line
        call matchadd('ErrorMsg', '  ', -1) " Two spaces (likely wrong 
indentation)
        call matchadd('ErrorMsg', 'for(', -1) "for without space
        call matchadd('ErrorMsg', 'if(', -1) " if without space
        call matchadd('ErrorMsg', 'while(', -1) " while without space
:endfu

" call the function on all opened files
autocmd WinEnter * if !exists('w:created') | call FuncHaikuCheck() | endif
autocmd BufWinEnter * call FuncHaikuCheck()

-- 
Adrien Destugues / PulkoMandy
Elève ingénieur ENSSAT EII1- www.enssat.fr
GSoC student for Haiku - http://haiku-os.org
GrafX2 project team - http://code.google.com/p/grafx2

Other related posts: