1" Vim syntax file
2" Language:	Spice circuit simulator input netlist
3" Maintainer:	Noam Halevy <Noam.Halevy.motorola.com>
4" Last Change:	12/08/99
5"
6" This is based on sh.vim by Lennart Schultz
7" but greatly simplified
8
9" For version 5.x: Clear all syntax items
10" For version 6.x: Quit when a syntax file was already loaded
11if version < 600
12  syntax clear
13elseif exists("b:current_syntax")
14  finish
15endif
16
17" spice syntax is case INsensitive
18syn case ignore
19
20syn keyword	spiceTodo	contained TODO
21
22syn match spiceComment  "^ \=\*.*$"
23syn match spiceComment  "\$.*$"
24
25" Numbers, all with engineering suffixes and optional units
26"==========================================================
27"floating point number, with dot, optional exponent
28syn match spiceNumber  "\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=\(meg\=\|[afpnumkg]\)\="
29"floating point number, starting with a dot, optional exponent
30syn match spiceNumber  "\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\(meg\=\|[afpnumkg]\)\="
31"integer number with optional exponent
32syn match spiceNumber  "\<[0-9]\+\(e[-+]\=[0-9]\+\)\=\(meg\=\|[afpnumkg]\)\="
33
34" Misc
35"=====
36syn match   spiceWrapLineOperator       "\\$"
37syn match   spiceWrapLineOperator       "^+"
38
39syn match   spiceStatement      "^ \=\.\I\+"
40
41" Matching pairs of parentheses
42"==========================================
43syn region  spiceParen transparent matchgroup=spiceOperator start="(" end=")" contains=ALLBUT,spiceParenError
44syn region  spiceSinglequote matchgroup=spiceOperator start=+'+ end=+'+
45
46" Errors
47"=======
48syn match spiceParenError ")"
49
50" Syncs
51" =====
52syn sync minlines=50
53
54" Define the default highlighting.
55" For version 5.7 and earlier: only when not done already
56" For version 5.8 and later: only when an item doesn't have highlighting yet
57if version >= 508 || !exists("did_spice_syntax_inits")
58  if version < 508
59    let did_spice_syntax_inits = 1
60    command -nargs=+ HiLink hi link <args>
61  else
62    command -nargs=+ HiLink hi def link <args>
63  endif
64
65  HiLink spiceTodo		Todo
66  HiLink spiceWrapLineOperator	spiceOperator
67  HiLink spiceSinglequote	spiceExpr
68  HiLink spiceExpr		Function
69  HiLink spiceParenError	Error
70  HiLink spiceStatement		Statement
71  HiLink spiceNumber		Number
72  HiLink spiceComment		Comment
73  HiLink spiceOperator		Operator
74
75  delcommand HiLink
76endif
77
78let b:current_syntax = "spice"
79
80" insert the following to $VIM/syntax/scripts.vim
81" to autodetect HSpice netlists and text listing output:
82"
83" " Spice netlists and text listings
84" elseif getline(1) =~ 'spice\>' || getline("$") =~ '^\.end'
85"   so <sfile>:p:h/spice.vim
86
87" vim: ts=8
88