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