Skip to content

Commit 9275366

Browse files
tony-ow0rp
andauthored
Add scadformat fixer for OpenSCAD (#4808)
Add scadformat to ALE --------- Co-authored-by: w0rp <w0rp@users.noreply.github.com>
1 parent b266086 commit 9275366

File tree

8 files changed

+63
-0
lines changed

8 files changed

+63
-0
lines changed

autoload/ale/fix/registry.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,11 @@ let s:default_registry = {
697697
\ 'suggested_filetypes': ['ruby'],
698698
\ 'description': 'A formatter for Ruby source code',
699699
\ },
700+
\ 'scadformat': {
701+
\ 'function': 'ale#fixers#scadformat#Fix',
702+
\ 'suggested_filetypes': ['openscad'],
703+
\ 'description': 'Formatter for scad files',
704+
\ },
700705
\ 'cljfmt': {
701706
\ 'function': 'ale#fixers#cljfmt#Fix',
702707
\ 'suggested_filetypes': ['clojure'],

autoload/ale/fixers/scadformat.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
" Author: tony o'dell <tony.odell@live.com>
2+
" Description: Fix scad files with scadformat
3+
4+
call ale#Set('openscad_scadformat_executable', 'scadformat')
5+
call ale#Set('openscad_scadformat_options', '')
6+
7+
function! ale#fixers#scadformat#Fix(buffer) abort
8+
let l:executable = ale#Var(a:buffer, 'openscad_scadformat_executable')
9+
let l:options = ale#Var(a:buffer, 'openscad_scadformat_options')
10+
11+
return {
12+
\ 'command': ale#Escape(l:executable)
13+
\ . (empty(l:options) ? '' : ' ' . l:options),
14+
\}
15+
endfunction

doc/ale-openscad.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,23 @@ g:ale_openscad_sca2d_options *g:ale_openscad_sca2d_options*
2121
This variable can be set to pass options to sca2d.
2222

2323

24+
===============================================================================
25+
scadformat *ale-openscad-scadformat*
26+
27+
g:ale_openscad_scadformat_executable *g:ale_openscad_scadformat_executable*
28+
*b:ale_openscad_scadformat_executable*
29+
Type: |String|
30+
Default: `'scadformat'`
31+
32+
See |ale-integrations-local-executables|
33+
34+
35+
g:ale_openscad_scadformat_options *g:ale_openscad_scadformat_options*
36+
*b:ale_openscad_scadformat_options*
37+
Type: |String|
38+
Default: `''`
39+
40+
This variable can be set to pass options to scadformat.
41+
2442
===============================================================================
2543
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

doc/ale-supported-languages-and-tools.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ Notes:
446446
* `yamllint`
447447
* OpenSCAD
448448
* `SCA2D`
449+
* `scadformat`
449450
* Packer
450451
* `packer-fmt-fixer`
451452
* Pascal

doc/ale.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,6 +3256,7 @@ documented in additional help files.
32563256
yamllint..............................|ale-openapi-yamllint|
32573257
openscad................................|ale-openscad-options|
32583258
sca2d.................................|ale-openscad-sca2d|
3259+
scadformat............................|ale-openscad-scadformat|
32593260
packer..................................|ale-packer-options|
32603261
packer-fmt-fixer......................|ale-packer-fmt-fixer|
32613262
pascal..................................|ale-pascal-options|

supported-tools.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ formatting.
455455
* [yamllint](https://yamllint.readthedocs.io/)
456456
* OpenSCAD
457457
* [SCA2D](https://gitlab.com/bath_open_instrumentation_group/sca2d) :floppy_disk:
458+
* [scadformat](https://github.com/hugheaves/scadformat)
458459
* Packer (HCL)
459460
* [packer-fmt-fixer](https://github.com/hashicorp/packer)
460461
* Pascal
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Before:
2+
Save g:ale_openscad_scadformat_executable
3+
Save g:ale_openscad_scadformat_options
4+
5+
let g:ale_openscad_scadformat_executable = 'xxx'
6+
let g:ale_openscad_scadformat_options = ''
7+
8+
call ale#test#SetDirectory('/testplugin/test/fixers')
9+
10+
After:
11+
Restore
12+
13+
call ale#test#RestoreDirectory()
14+
15+
Execute(scadformat - defaults OK):
16+
call ale#test#SetFilename('../test-files/openscad/dummy.scad')
17+
18+
AssertEqual
19+
\ {
20+
\ 'command': ale#Escape('xxx')
21+
\ },
22+
\ ale#fixers#scadformat#Fix(bufnr(''))

test/test-files/openscad/dummy.scad

Whitespace-only changes.

0 commit comments

Comments
 (0)