diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-09 17:00:24 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-09 17:00:24 +0200 |
commit | 7c474e5c9218d870dabba00745220dff5aa671b2 (patch) | |
tree | 0939e06ae13b4145bfb5e2fe98bf3c86ce491c2f | |
parent | 1a096f0901264629947afb89436019895e5e7ef5 (diff) | |
download | vim-polyglot-7c474e5c9218d870dabba00745220dff5aa671b2.tar.gz vim-polyglot-7c474e5c9218d870dabba00745220dff5aa671b2.zip |
Add OpenSCAD support, closes #702
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | autoload/polyglot/init.vim | 4 | ||||
-rw-r--r-- | autoload/polyglot/sleuth.vim | 1 | ||||
-rw-r--r-- | ftplugin/openscad.vim | 18 | ||||
-rw-r--r-- | packages.yaml | 8 | ||||
-rw-r--r-- | syntax/openscad.vim | 93 | ||||
-rw-r--r-- | tests/filetypes.vim | 1 |
7 files changed, 127 insertions, 1 deletions
@@ -7,7 +7,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 120+ times faster** than the <!--Package Count-->603<!--/Package Count--> packages it consists of. +- It **installs and updates 120+ times faster** than the <!--Package Count-->604<!--/Package Count--> packages it consists of. - It is also more secure (scripts loaded for every filetype are generated by vim-polyglot) - Best syntax and indentation support (no other features). Hand-selected language packs. - Automatically detects indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth), can be disabled) @@ -140,6 +140,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [octave](https://github.com/McSinyx/vim-octave) (Syntax highlighting for oct and m files) - [odin](https://github.com/Tetralux/odin.vim) (Odin syntax highlighting for odin files) - [opencl](https://github.com/petRUShka/vim-opencl) (OpenCL syntax highlighting for cl and opencl files) +- [openscad](https://github.com/sirtaj/vim-openscad) (Syntax highlighting for scad files) - [perl](https://github.com/vim-perl/vim-perl) (Perl syntax highlighting for pl, al, cgi, fcgi, perl and 12 more files) - [pest](https://github.com/pest-parser/pest.vim) (Syntax highlighting for pest files) - [pgsql](https://github.com/lifepillar/pgsql.vim) (PLpgSQL syntax highlighting for pgsql files) diff --git a/autoload/polyglot/init.vim b/autoload/polyglot/init.vim index 2c76d854..ac3bf8e8 100644 --- a/autoload/polyglot/init.vim +++ b/autoload/polyglot/init.vim @@ -169,6 +169,10 @@ let did_load_filetypes = 1 " DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE +if !has_key(g:polyglot_is_disabled, 'openscad') + au BufNewFile,BufRead *.scad setf openscad +endif + if !has_key(g:polyglot_is_disabled, 'sway') au BufNewFile,BufRead *sway/config setf sway endif diff --git a/autoload/polyglot/sleuth.vim b/autoload/polyglot/sleuth.vim index 1912384c..c8f09297 100644 --- a/autoload/polyglot/sleuth.vim +++ b/autoload/polyglot/sleuth.vim @@ -382,6 +382,7 @@ let s:globs = { \ 'opam': '*.opam,*.opam.template,opam', \ 'opencl': '*.cl,*.opencl', \ 'openroad': '*.or', + \ 'openscad': '*.scad', \ 'opl': '*.[Oo][Pp][Ll]', \ 'ora': '*.ora', \ 'pamconf': '', diff --git a/ftplugin/openscad.vim b/ftplugin/openscad.vim new file mode 100644 index 00000000..3daa1687 --- /dev/null +++ b/ftplugin/openscad.vim @@ -0,0 +1,18 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'openscad', 'ftplugin/openscad.vim') + finish +endif + +" Blatantly stolen from vim74\ftplugin\c.vim + +" Set 'formatoptions' to break comment lines but not other lines, +" and insert the comment leader when hitting <CR> 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 diff --git a/packages.yaml b/packages.yaml index 25ee0e6f..b6c65e9e 100644 --- a/packages.yaml +++ b/packages.yaml @@ -5592,3 +5592,11 @@ filetypes: patterns: - pattern: '*sway/config' description: Sway Configuration +--- +name: openscad +remote: sirtaj/vim-openscad +filetypes: +- name: openscad + patterns: + - pattern: '*.scad' + description: OpenSCAD 3D modeling language diff --git a/syntax/openscad.vim b/syntax/openscad.vim new file mode 100644 index 00000000..40156d58 --- /dev/null +++ b/syntax/openscad.vim @@ -0,0 +1,93 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'openscad', 'syntax/openscad.vim') + finish +endif + +" Vim syntax file +" Language: OpenSCAD +" Maintainer: Sirtaj Singh Kang <sirtaj-vim@sirtaj.net> +" 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 assert +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" diff --git a/tests/filetypes.vim b/tests/filetypes.vim index 39b280e6..29b457f2 100644 --- a/tests/filetypes.vim +++ b/tests/filetypes.vim @@ -650,6 +650,7 @@ call TestFiletype('jsonc') call TestFiletype('gleam') call TestFiletype('hjson') call TestFiletype('sway') +call TestFiletype('openscad') " DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE |