Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Spice circuit simulator input netlist |
| 3 | " Maintainer: Noam Halevy <Noam.Halevy.motorola.com> |
Bram Moolenaar | c873442 | 2012-06-01 22:38:45 +0200 | [diff] [blame] | 4 | " Last Change: 2012 Jun 01 |
| 5 | " (Dominique Pelle added @Spell) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
| 12 | if version < 600 |
| 13 | syntax clear |
| 14 | elseif exists("b:current_syntax") |
| 15 | finish |
| 16 | endif |
| 17 | |
| 18 | " spice syntax is case INsensitive |
| 19 | syn case ignore |
| 20 | |
| 21 | syn keyword spiceTodo contained TODO |
| 22 | |
Bram Moolenaar | c873442 | 2012-06-01 22:38:45 +0200 | [diff] [blame] | 23 | syn match spiceComment "^ \=\*.*$" contains=@Spell |
| 24 | syn match spiceComment "\$.*$" contains=@Spell |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 25 | |
| 26 | " Numbers, all with engineering suffixes and optional units |
| 27 | "========================================================== |
| 28 | "floating point number, with dot, optional exponent |
| 29 | syn match spiceNumber "\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=\(meg\=\|[afpnumkg]\)\=" |
| 30 | "floating point number, starting with a dot, optional exponent |
| 31 | syn match spiceNumber "\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\(meg\=\|[afpnumkg]\)\=" |
| 32 | "integer number with optional exponent |
| 33 | syn match spiceNumber "\<[0-9]\+\(e[-+]\=[0-9]\+\)\=\(meg\=\|[afpnumkg]\)\=" |
| 34 | |
| 35 | " Misc |
| 36 | "===== |
| 37 | syn match spiceWrapLineOperator "\\$" |
| 38 | syn match spiceWrapLineOperator "^+" |
| 39 | |
| 40 | syn match spiceStatement "^ \=\.\I\+" |
| 41 | |
| 42 | " Matching pairs of parentheses |
| 43 | "========================================== |
| 44 | syn region spiceParen transparent matchgroup=spiceOperator start="(" end=")" contains=ALLBUT,spiceParenError |
| 45 | syn region spiceSinglequote matchgroup=spiceOperator start=+'+ end=+'+ |
| 46 | |
| 47 | " Errors |
| 48 | "======= |
| 49 | syn match spiceParenError ")" |
| 50 | |
| 51 | " Syncs |
| 52 | " ===== |
| 53 | syn 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 |
| 58 | if 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 |
| 77 | endif |
| 78 | |
| 79 | let 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 |