diff --git a/README.md b/README.md index 637b22f..6b72f7a 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ If you need full functionality of any plugin, please use it directly with your p - [fish](https://github.com/dag/vim-fish) (syntax, indent, compiler, autoload, ftplugin) - [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin) - [glsl](https://github.com/tikhomirov/vim-glsl) (syntax, indent) +- [gmpl](https://github.com/maelvalais/gmpl.vim) (syntax) - [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) (syntax) - [go](https://github.com/fatih/vim-go) (syntax, compiler, indent) - [graphql](https://github.com/jparise/vim-graphql) (syntax, indent, ftplugin) @@ -95,6 +96,7 @@ If you need full functionality of any plugin, please use it directly with your p - [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin) - [octave](https://github.com/vim-scripts/octave.vim--) (syntax) - [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin) +- [openscad](https://github.com/sirtaj/vim-openscad) (syntax, ftplugin) - [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin) - [pgsql](https://github.com/exu/pgsql.vim) (syntax) - [php](https://github.com/StanAngeloff/php.vim) (syntax) diff --git a/build b/build index b8bf853..7b07b8e 100755 --- a/build +++ b/build @@ -134,6 +134,8 @@ PACKS=" erlang:vim-erlang/vim-erlang-runtime fish:dag/vim-fish git:tpope/vim-git + gmpl:maelvalais/gmpl.vim + openscad:sirtaj/vim-openscad glsl:tikhomirov/vim-glsl gnuplot:vim-scripts/gnuplot-syntax-highlighting go:fatih/vim-go:_BASIC diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 8f2f926..528eaae 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -282,6 +282,17 @@ autocmd BufNewFile,BufRead * \ endif augroup END +augroup filetypedetect +" gmpl:maelvalais/gmpl.vim +au BufRead,BufNewFile *.mod set filetype=gmpl +augroup END + +augroup filetypedetect +" openscad:sirtaj/vim-openscad +au BufRead,BufNewFile *.scad setfiletype openscad +an 50.80.265 &Syntax.NO.OpenSCAD :cal SetSyn("openscad") +augroup END + augroup filetypedetect " glsl:tikhomirov/vim-glsl " Language: OpenGL Shading Language diff --git a/ftplugin/openscad.vim b/ftplugin/openscad.vim new file mode 100644 index 0000000..2933c23 --- /dev/null +++ b/ftplugin/openscad.vim @@ -0,0 +1,18 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'openscad') == -1 + +" Blatantly stolen from vim74\ftplugin\c.vim + +" Set 'formatoptions' to break comment lines but not other lines, +" and insert the comment leader when hitting or using "o". +setlocal fo-=t fo+=croql + +" Set 'comments' to format dashed lists in comments. +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// + +" Win32 can filter files in the browse dialog +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "OpenSCAD Source Files (*.scad)\t*.scad\n" . + \ "All Files (*.*)\t*.*\n" +endif + +endif diff --git a/syntax/gmpl.vim b/syntax/gmpl.vim new file mode 100644 index 0000000..2b8d712 --- /dev/null +++ b/syntax/gmpl.vim @@ -0,0 +1,122 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gmpl') == -1 + +" Vim syntax file +" Language: GMPL +" Maintainer: Mark Mba Wright +" Latest Revision: 9 July 2012 + +if exists("b:current_syntax") + finish +endif + +syn sync fromstart + + +syn match gmplArithmeticSetOperator "\.\." + +" Integer with - + or nothing in front +syn match gmplNumber '\d\+' +syn match gmplNumber '[-+]\d\+' + +" Floating point gmplNumber with decimal no E or e (+,-) +syn match gmplNumber '\d*\.\d\+' +syn match gmplNumber '[-+]\d*\.\d\+' + +" Floating point like gmplNumber with E and no decimal point (+,-) +syn match gmplNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+' +syn match gmplNumber '\d[[:digit:]]*[eE][\-+]\=\d\+' + +" Floating point like gmplNumber with E and decimal point (+,-) +syn match gmplNumber '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' +syn match gmplNumber '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' +syn match gmplIndex /\<\%(in\>\)\@!\w*/ contained contains=gmplKeyword,gmplNumber +syn match gmplLabel '[a-zA-Z][a-zA-Z0-9_]*' +syn match gmplArithmeticOperator "[-+]" +syn match gmplArithmeticOperator "\.\=[*/\\^]" +syn match gmplRelationalOperator "[=~]=" +syn match gmplRelationalOperator "[<>]=\=" +" syn match gmplLogicalOperator "[&|~] + +" match indeces + +" comments +syn match gmplComment /\/\*.\{-}\*\// +syn region gmplComment start="/\*" end="\*/" +syn match gmplComment '#.\{-}$' + +" strings +syn region gmplString start="\"" end="\"" +syn region gmplString start="\'" end="\'" contains=gmplStringToken +syn match gmplStringToken '\%[a-z]' contained + +" Keywords +syn keyword gmplKeyword and else by if cross in diff inter div less mod union not within or symdiff then +syn keyword gmplKeyword minimize maximize solve +syn keyword gmplType set var param nextgroup=gmplLabel skipwhite + +" Regions +syn region gmplIndexExpression start="{" end="}" transparent contains=gmplIndex,gmplIndexExpression +syn region gmplIndexGroup start="\[" end="\]" transparent contains=gmplIndex +" syn region gmplParen start="(" end=")" + +"" catch errors caused by wrong parenthesis +syn match gmplParensError ")\|}\|\]" +syn match gmplParensErrA contained "\]" +syn match gmplParensErrC contained "}" + + +hi level1c ctermfg=brown guifg=brown +hi level2c ctermfg=darkgreen guifg=darkgreen gui=bold +hi level3c ctermfg=Darkblue guifg=Darkblue +hi level4c ctermfg=darkmagenta guifg=darkmagenta gui=bold +hi level5c ctermfg=darkcyan guifg=darkcyan +hi level6c ctermfg=white guifg=white gui=bold +hi level7c ctermfg=darkred guifg=darkred +hi level8c ctermfg=blue guifg=blue gui=bold +hi level9c ctermfg=darkgray guifg=darkgray +hi level10c ctermfg=brown guifg=brown gui=bold +hi level11c ctermfg=darkgreen guifg=darkgreen +hi level12c ctermfg=Darkblue guifg=Darkblue gui=bold +hi level13c ctermfg=darkmagenta guifg=darkmagenta +hi level14c ctermfg=darkcyan guifg=darkcyan gui=bold +hi level15c ctermfg=gray guifg=gray + +" These are the regions for each pair. +" This could be improved, perhaps, by makeing them match [ and { also, +" but I'm not going to take the time to figure out haw to make the +" end pattern match only the proper type. +syn region level1 matchgroup=level1c start=/(/ end=/)/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level2 matchgroup=level2c start=/(/ end=/)/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level3 matchgroup=level3c start=/(/ end=/)/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level4 matchgroup=level4c start=/(/ end=/)/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level5 matchgroup=level5c start=/(/ end=/)/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level6 matchgroup=level6c start=/(/ end=/)/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level7 matchgroup=level7c start=/(/ end=/)/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level8 matchgroup=level8c start=/(/ end=/)/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level9 matchgroup=level9c start=/(/ end=/)/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level10 matchgroup=level10c start=/(/ end=/)/ contains=TOP,level10,level11,level12,level13,level14,level15, NoInParens +syn region level11 matchgroup=level11c start=/(/ end=/)/ contains=TOP,level11,level12,level13,level14,level15, NoInParens +syn region level12 matchgroup=level12c start=/(/ end=/)/ contains=TOP,level12,level13,level14,level15, NoInParens +syn region level13 matchgroup=level13c start=/(/ end=/)/ contains=TOP,level13,level14,level15, NoInParens +syn region level14 matchgroup=level14c start=/(/ end=/)/ contains=TOP,level14,level15, NoInParens +syn region level15 matchgroup=level15c start=/(/ end=/)/ contains=TOP,level15, NoInParens + +let b:current_syntax = "gmpl" + +hi def link gmplKeyword Keyword +hi def link gmplParensError Error +hi def link gmplParensErrA Error +hi def link gmplParensErrB Error +hi def link gmplParensErrC Error +" hi def link gmplIndexExpression Label +" hi def link gmplParen Label +" hi def link gmplIndexGroup Label +hi def link gmplIndex Identifier +hi def link gmplNumber Number +hi def link gmplComment Comment +hi def link gmplType Type +hi def link gmplLabel Keyword +hi def link gmplString String +hi def link gmplStringToken Special + +endif diff --git a/syntax/openscad.vim b/syntax/openscad.vim new file mode 100644 index 0000000..ba1b347 --- /dev/null +++ b/syntax/openscad.vim @@ -0,0 +1,93 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'openscad') == -1 + +" Vim syntax file +" Language: OpenSCAD +" Maintainer: Sirtaj Singh Kang +" Last Changed: 2013 March 05 + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + + +"syn keyword openscadFunctionDef function +syn keyword openscadFunctionDef function nextgroup=openscadFunction skipwhite skipempty +syn match openscadFunction /\<\h\w*\>/ contained display + +"syn keyword openscadModuleDef module +syn keyword openscadModuleDef module nextgroup=openscadModule skipwhite skipempty +syn match openscadModule /\<\h\w*\>/ contained display + +syn keyword openscadStatement echo assign let +syn keyword openscadConditional if else +syn keyword openscadRepeat for intersection_for +syn keyword openscadInclude include use +syn keyword openscadCsgKeyword union difference intersection render intersection_for +syn keyword openscadTransform scale rotate translate mirror multmatrix color minkowski hull projection linear_extrude rotate_extrude offset +syn keyword openscadPrimitiveSolid cube sphere cylinder polyhedron surface +syn keyword openscadPrimitive2D square circle polygon import_dxf text +syn keyword openscadPrimitiveImport import child children + +syn match openscadSpecialVariable "\$[a-zA-Z]\+\>" display +syn match openscadModifier "^\s*[\*\!\#\%]" display + +syn match openscadNumbers "\<\d\|\.\d" contains=openscadNumber display transparent +syn match openscadNumber "\d\+" display contained +syn match openscadNumber "\.\d\+" display contained + +syn region openscadString start=/"/ skip=/\\"/ end=/"/ + +syn keyword openscadBoolean true false + +syn keyword openscadCommentTodo TODO FIXME XXX contained display +syn match openscadInlineComment ://.*$: contains=openscadCommentTodo +syn region openscadBlockComment start=:/\*: end=:\*/: fold contains=openscadCommentTodo + +syn region openscadBlock start="{" end="}" transparent fold +syn region openscadVector start="\[" end="\]" transparent fold + +syn keyword openscadBuiltin abs acos asin atan atan2 ceil cos exp floor ln log +syn keyword openscadBuiltin lookup max min pow rands round sign sin sqrt tan +syn keyword openscadBuiltin str len search version version_num concat chr +syn keyword openscadBuiltin dxf_cross dxf_dim + +hi def link openscadFunctionDef Structure +hi def link openscadFunction Function +hi def link openscadModuleDef Structure +hi def link openscadModule Function +hi def link openscadBlockComment Comment +hi def link openscadBoolean Boolean +hi def link openscadBuiltin Function +hi def link openscadConditional Conditional +hi def link openscadCsgKeyword Structure +hi def link openscadInclude Include +hi def link openscadInlineComment Comment +hi def link openscadModifier Special +hi def link openscadStatement Statement +hi def link openscadNumbers Number +hi def link openscadNumber Number +hi def link openscadPrimitiveSolid Keyword +hi def link openscadPrimitive2D Keyword +hi def link openscadPrimitiveImport Keyword +hi def link openscadRepeat Repeat +hi def link openscadSpecialVariable Special +hi def link openscadString String +hi def link openscadTransform Statement +hi def link openscadCommentTodo Todo + +" Blatantly stolen from vim74\syntax\c.vim +"when wanted, highlight trailing white space +if exists("openscad_space_errors") + if !exists("openscad_no_trail_space_error") + syn match openscadSpaceError display excludenl "\s\+$" + endif + if !exists("openscad_no_tab_space_error") + syn match openscadSpaceError display " \+\t"me=e-1 + endif +endif + +let b:current_syntax = "openscad" + +endif