|
| 1 | +if polyglot#init#is_disabled(expand('<sfile>:p'), 'openscad', 'syntax/openscad.vim') |
| 2 | + finish |
| 3 | +endif |
| 4 | + |
| 5 | +" Vim syntax file |
| 6 | +" Language: OpenSCAD |
| 7 | +" Maintainer: Sirtaj Singh Kang <[email protected]> |
| 8 | +" Last Changed: 2013 March 05 |
| 9 | + |
| 10 | +if version < 600 |
| 11 | + syntax clear |
| 12 | +elseif exists("b:current_syntax") |
| 13 | + finish |
| 14 | +endif |
| 15 | + |
| 16 | + |
| 17 | +"syn keyword openscadFunctionDef function |
| 18 | +syn keyword openscadFunctionDef function nextgroup=openscadFunction skipwhite skipempty |
| 19 | +syn match openscadFunction /\<\h\w*\>/ contained display |
| 20 | + |
| 21 | +"syn keyword openscadModuleDef module |
| 22 | +syn keyword openscadModuleDef module nextgroup=openscadModule skipwhite skipempty |
| 23 | +syn match openscadModule /\<\h\w*\>/ contained display |
| 24 | + |
| 25 | +syn keyword openscadStatement echo assign let assert |
| 26 | +syn keyword openscadConditional if else |
| 27 | +syn keyword openscadRepeat for intersection_for |
| 28 | +syn keyword openscadInclude include use |
| 29 | +syn keyword openscadCsgKeyword union difference intersection render intersection_for |
| 30 | +syn keyword openscadTransform scale rotate translate mirror multmatrix color minkowski hull projection linear_extrude rotate_extrude offset |
| 31 | +syn keyword openscadPrimitiveSolid cube sphere cylinder polyhedron surface |
| 32 | +syn keyword openscadPrimitive2D square circle polygon import_dxf text |
| 33 | +syn keyword openscadPrimitiveImport import child children |
| 34 | + |
| 35 | +syn match openscadSpecialVariable "\$[a-zA-Z]\+\>" display |
| 36 | +syn match openscadModifier "^\s*[\*\!\#\%]" display |
| 37 | + |
| 38 | +syn match openscadNumbers "\<\d\|\.\d" contains=openscadNumber display transparent |
| 39 | +syn match openscadNumber "\d\+" display contained |
| 40 | +syn match openscadNumber "\.\d\+" display contained |
| 41 | + |
| 42 | +syn region openscadString start=/"/ skip=/\\"/ end=/"/ |
| 43 | + |
| 44 | +syn keyword openscadBoolean true false |
| 45 | + |
| 46 | +syn keyword openscadCommentTodo TODO FIXME XXX contained display |
| 47 | +syn match openscadInlineComment ://.*$: contains=openscadCommentTodo |
| 48 | +syn region openscadBlockComment start=:/\*: end=:\*/: fold contains=openscadCommentTodo |
| 49 | + |
| 50 | +syn region openscadBlock start="{" end="}" transparent fold |
| 51 | +syn region openscadVector start="\[" end="\]" transparent fold |
| 52 | + |
| 53 | +syn keyword openscadBuiltin abs acos asin atan atan2 ceil cos exp floor ln log |
| 54 | +syn keyword openscadBuiltin lookup max min pow rands round sign sin sqrt tan |
| 55 | +syn keyword openscadBuiltin str len search version version_num concat chr |
| 56 | +syn keyword openscadBuiltin dxf_cross dxf_dim |
| 57 | + |
| 58 | +hi def link openscadFunctionDef Structure |
| 59 | +hi def link openscadFunction Function |
| 60 | +hi def link openscadModuleDef Structure |
| 61 | +hi def link openscadModule Function |
| 62 | +hi def link openscadBlockComment Comment |
| 63 | +hi def link openscadBoolean Boolean |
| 64 | +hi def link openscadBuiltin Function |
| 65 | +hi def link openscadConditional Conditional |
| 66 | +hi def link openscadCsgKeyword Structure |
| 67 | +hi def link openscadInclude Include |
| 68 | +hi def link openscadInlineComment Comment |
| 69 | +hi def link openscadModifier Special |
| 70 | +hi def link openscadStatement Statement |
| 71 | +hi def link openscadNumbers Number |
| 72 | +hi def link openscadNumber Number |
| 73 | +hi def link openscadPrimitiveSolid Keyword |
| 74 | +hi def link openscadPrimitive2D Keyword |
| 75 | +hi def link openscadPrimitiveImport Keyword |
| 76 | +hi def link openscadRepeat Repeat |
| 77 | +hi def link openscadSpecialVariable Special |
| 78 | +hi def link openscadString String |
| 79 | +hi def link openscadTransform Statement |
| 80 | +hi def link openscadCommentTodo Todo |
| 81 | + |
| 82 | +" Blatantly stolen from vim74\syntax\c.vim |
| 83 | +"when wanted, highlight trailing white space |
| 84 | +if exists("openscad_space_errors") |
| 85 | + if !exists("openscad_no_trail_space_error") |
| 86 | + syn match openscadSpaceError display excludenl "\s\+$" |
| 87 | + endif |
| 88 | + if !exists("openscad_no_tab_space_error") |
| 89 | + syn match openscadSpaceError display " \+\t"me=e-1 |
| 90 | + endif |
| 91 | +endif |
| 92 | + |
| 93 | +let b:current_syntax = "openscad" |
0 commit comments