Promela syntax highlighting for vim

A part of my professional interests is the SPIN model checker and its native language Promela. After a while of editing Promela sources, I've implemented a syntax file for the vim editor.

Installation

To install, download the promela.vim file and copy it to the vim syntax directory. That's usually at ~/.vim/syntax for the current user. If the directory doesn't exist, create it. Then inform vim that the file is ready by editing (creating) ~/.vim/filetype.vim:

augroup filetypedetect
" Promela
au BufNewFile,BufRead *.promela,*.prm		setf promela
augroup END

Vim will use the proper syntax automatically for all *.promela and *.prm files. If the syntax highlighting is not enabled by default, enable it by typing :syntax on. Folding can be acticated by :set foldmethod=syntax.

Screenshot

Here it is (your default colors will apply, of course):

 1 #if 0
 2 Preprocessor comment
 3 #endif
 4 
 5 #include "syn"
 6 #define MESSAGEQ 10 /* Channel size */
 7 
 8 */ Error highlight
 9 
10  mtype = { a, b, c, d, e};
11  chan sender = [MESSAGEQ] of { mtype, byte };
12  chan recv = [MESSAGEQ] of { mtype, byte };
13 
14 active proctype eve(chan in, out)
15 +--  8 lines: {-----------------------------------------------------------------------
23 
24 active proctype john()
25 +-- 10 lines: {-----------------------------------------------------------------------
35 
36 active proctype adam(chan in, out)
37 {
38         byte b2; // message data FIXME
39         bit  bt;
40  S1:    bt = (bt+1)%MAX;
41         assert( wr == (lw+1)%MIN);
42         out!bt,1;
43         if
44         :: goto S4
45         :: printf( "TOUCH 2\n"); goto S5
46         fi;
47  S2:    out!mt,0;
48         goto S4;
49         // ...
50 }
51 

Download

Syntax file: promela.vim

2006 Viliam Holub