mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
Add scadformat fixer for OpenSCAD (#4808)
Add scadformat to ALE --------- Co-authored-by: w0rp <w0rp@users.noreply.github.com>
This commit is contained in:
@@ -697,6 +697,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['ruby'],
|
\ 'suggested_filetypes': ['ruby'],
|
||||||
\ 'description': 'A formatter for Ruby source code',
|
\ 'description': 'A formatter for Ruby source code',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'scadformat': {
|
||||||
|
\ 'function': 'ale#fixers#scadformat#Fix',
|
||||||
|
\ 'suggested_filetypes': ['openscad'],
|
||||||
|
\ 'description': 'Formatter for scad files',
|
||||||
|
\ },
|
||||||
\ 'cljfmt': {
|
\ 'cljfmt': {
|
||||||
\ 'function': 'ale#fixers#cljfmt#Fix',
|
\ 'function': 'ale#fixers#cljfmt#Fix',
|
||||||
\ 'suggested_filetypes': ['clojure'],
|
\ 'suggested_filetypes': ['clojure'],
|
||||||
|
|||||||
15
autoload/ale/fixers/scadformat.vim
Normal file
15
autoload/ale/fixers/scadformat.vim
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
" Author: tony o'dell <tony.odell@live.com>
|
||||||
|
" Description: Fix scad files with scadformat
|
||||||
|
|
||||||
|
call ale#Set('openscad_scadformat_executable', 'scadformat')
|
||||||
|
call ale#Set('openscad_scadformat_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#scadformat#Fix(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'openscad_scadformat_executable')
|
||||||
|
let l:options = ale#Var(a:buffer, 'openscad_scadformat_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||||
|
\}
|
||||||
|
endfunction
|
||||||
@@ -21,5 +21,23 @@ g:ale_openscad_sca2d_options *g:ale_openscad_sca2d_options*
|
|||||||
This variable can be set to pass options to sca2d.
|
This variable can be set to pass options to sca2d.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
scadformat *ale-openscad-scadformat*
|
||||||
|
|
||||||
|
g:ale_openscad_scadformat_executable *g:ale_openscad_scadformat_executable*
|
||||||
|
*b:ale_openscad_scadformat_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'scadformat'`
|
||||||
|
|
||||||
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_openscad_scadformat_options *g:ale_openscad_scadformat_options*
|
||||||
|
*b:ale_openscad_scadformat_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass options to scadformat.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|||||||
@@ -446,6 +446,7 @@ Notes:
|
|||||||
* `yamllint`
|
* `yamllint`
|
||||||
* OpenSCAD
|
* OpenSCAD
|
||||||
* `SCA2D`
|
* `SCA2D`
|
||||||
|
* `scadformat`
|
||||||
* Packer
|
* Packer
|
||||||
* `packer-fmt-fixer`
|
* `packer-fmt-fixer`
|
||||||
* Pascal
|
* Pascal
|
||||||
|
|||||||
@@ -3256,6 +3256,7 @@ documented in additional help files.
|
|||||||
yamllint..............................|ale-openapi-yamllint|
|
yamllint..............................|ale-openapi-yamllint|
|
||||||
openscad................................|ale-openscad-options|
|
openscad................................|ale-openscad-options|
|
||||||
sca2d.................................|ale-openscad-sca2d|
|
sca2d.................................|ale-openscad-sca2d|
|
||||||
|
scadformat............................|ale-openscad-scadformat|
|
||||||
packer..................................|ale-packer-options|
|
packer..................................|ale-packer-options|
|
||||||
packer-fmt-fixer......................|ale-packer-fmt-fixer|
|
packer-fmt-fixer......................|ale-packer-fmt-fixer|
|
||||||
pascal..................................|ale-pascal-options|
|
pascal..................................|ale-pascal-options|
|
||||||
|
|||||||
@@ -455,6 +455,7 @@ formatting.
|
|||||||
* [yamllint](https://yamllint.readthedocs.io/)
|
* [yamllint](https://yamllint.readthedocs.io/)
|
||||||
* OpenSCAD
|
* OpenSCAD
|
||||||
* [SCA2D](https://gitlab.com/bath_open_instrumentation_group/sca2d) :floppy_disk:
|
* [SCA2D](https://gitlab.com/bath_open_instrumentation_group/sca2d) :floppy_disk:
|
||||||
|
* [scadformat](https://github.com/hugheaves/scadformat)
|
||||||
* Packer (HCL)
|
* Packer (HCL)
|
||||||
* [packer-fmt-fixer](https://github.com/hashicorp/packer)
|
* [packer-fmt-fixer](https://github.com/hashicorp/packer)
|
||||||
* Pascal
|
* Pascal
|
||||||
|
|||||||
22
test/fixers/test_scadformat_fixer.vader
Normal file
22
test/fixers/test_scadformat_fixer.vader
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Before:
|
||||||
|
Save g:ale_openscad_scadformat_executable
|
||||||
|
Save g:ale_openscad_scadformat_options
|
||||||
|
|
||||||
|
let g:ale_openscad_scadformat_executable = 'xxx'
|
||||||
|
let g:ale_openscad_scadformat_options = ''
|
||||||
|
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(scadformat - defaults OK):
|
||||||
|
call ale#test#SetFilename('../test-files/openscad/dummy.scad')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('xxx')
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#scadformat#Fix(bufnr(''))
|
||||||
0
test/test-files/openscad/dummy.scad
Normal file
0
test/test-files/openscad/dummy.scad
Normal file
Reference in New Issue
Block a user