Skip to content

Commit 7c474e5

Browse files
committed
Add OpenSCAD support, closes #702
1 parent 1a096f0 commit 7c474e5

File tree

7 files changed

+127
-1
lines changed

7 files changed

+127
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A collection of language packs for Vim.
77
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
88
99
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
10-
- It **installs and updates 120+ times faster** than the <!--Package Count-->603<!--/Package Count--> packages it consists of.
10+
- It **installs and updates 120+ times faster** than the <!--Package Count-->604<!--/Package Count--> packages it consists of.
1111
- It is also more secure (scripts loaded for every filetype are generated by vim-polyglot)
1212
- Best syntax and indentation support (no other features). Hand-selected language packs.
1313
- 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
140140
- [octave](https://github.com/McSinyx/vim-octave) (Syntax highlighting for oct and m files)
141141
- [odin](https://github.com/Tetralux/odin.vim) (Odin syntax highlighting for odin files)
142142
- [opencl](https://github.com/petRUShka/vim-opencl) (OpenCL syntax highlighting for cl and opencl files)
143+
- [openscad](https://github.com/sirtaj/vim-openscad) (Syntax highlighting for scad files)
143144
- [perl](https://github.com/vim-perl/vim-perl) (Perl syntax highlighting for pl, al, cgi, fcgi, perl and 12 more files)
144145
- [pest](https://github.com/pest-parser/pest.vim) (Syntax highlighting for pest files)
145146
- [pgsql](https://github.com/lifepillar/pgsql.vim) (PLpgSQL syntax highlighting for pgsql files)

autoload/polyglot/init.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ let did_load_filetypes = 1
169169

170170
" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE
171171

172+
if !has_key(g:polyglot_is_disabled, 'openscad')
173+
au BufNewFile,BufRead *.scad setf openscad
174+
endif
175+
172176
if !has_key(g:polyglot_is_disabled, 'sway')
173177
au BufNewFile,BufRead *sway/config setf sway
174178
endif

autoload/polyglot/sleuth.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ let s:globs = {
382382
\ 'opam': '*.opam,*.opam.template,opam',
383383
\ 'opencl': '*.cl,*.opencl',
384384
\ 'openroad': '*.or',
385+
\ 'openscad': '*.scad',
385386
\ 'opl': '*.[Oo][Pp][Ll]',
386387
\ 'ora': '*.ora',
387388
\ 'pamconf': '',

ftplugin/openscad.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if polyglot#init#is_disabled(expand('<sfile>:p'), 'openscad', 'ftplugin/openscad.vim')
2+
finish
3+
endif
4+
5+
" Blatantly stolen from vim74\ftplugin\c.vim
6+
7+
" Set 'formatoptions' to break comment lines but not other lines,
8+
" and insert the comment leader when hitting <CR> or using "o".
9+
setlocal fo-=t fo+=croql
10+
11+
" Set 'comments' to format dashed lists in comments.
12+
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
13+
14+
" Win32 can filter files in the browse dialog
15+
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
16+
let b:browsefilter = "OpenSCAD Source Files (*.scad)\t*.scad\n" .
17+
\ "All Files (*.*)\t*.*\n"
18+
endif

packages.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5592,3 +5592,11 @@ filetypes:
55925592
patterns:
55935593
- pattern: '*sway/config'
55945594
description: Sway Configuration
5595+
---
5596+
name: openscad
5597+
remote: sirtaj/vim-openscad
5598+
filetypes:
5599+
- name: openscad
5600+
patterns:
5601+
- pattern: '*.scad'
5602+
description: OpenSCAD 3D modeling language

syntax/openscad.vim

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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"

tests/filetypes.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ call TestFiletype('jsonc')
650650
call TestFiletype('gleam')
651651
call TestFiletype('hjson')
652652
call TestFiletype('sway')
653+
call TestFiletype('openscad')
653654

654655
" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE
655656

0 commit comments

Comments
 (0)