forked from github-mirrors/ale
Add support for Packer (#4192)
* Add support for HashiCorp Packer * Add test for packer fmt * Add doc for HCL/Packer * Add link to Packer doc * Also suggest packer fix for packer ft * Add more links to TOC
This commit is contained in:
parent
b611fde718
commit
429f5a1447
|
@ -436,6 +436,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['hcl', 'terraform'],
|
\ 'suggested_filetypes': ['hcl', 'terraform'],
|
||||||
\ 'description': 'Fix tf and hcl files with terraform fmt.',
|
\ 'description': 'Fix tf and hcl files with terraform fmt.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'packer': {
|
||||||
|
\ 'function': 'ale#fixers#packer#Fix',
|
||||||
|
\ 'suggested_filetypes': ['hcl', 'packer'],
|
||||||
|
\ 'description': 'Fix Packer HCL files with packer fmt.',
|
||||||
|
\ },
|
||||||
\ 'crystal': {
|
\ 'crystal': {
|
||||||
\ 'function': 'ale#fixers#crystal#Fix',
|
\ 'function': 'ale#fixers#crystal#Fix',
|
||||||
\ 'suggested_filetypes': ['cr'],
|
\ 'suggested_filetypes': ['cr'],
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
" Author: Zhuoyun Wei <wzyboy@wzyboy.org>
|
||||||
|
" Description: Fixer for Packer HCL files
|
||||||
|
|
||||||
|
call ale#Set('packer_fmt_executable', 'packer')
|
||||||
|
call ale#Set('packer_fmt_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#packer#Fix(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'packer_fmt_executable')
|
||||||
|
let l:options = ale#Var(a:buffer, 'packer_fmt_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . ' fmt'
|
||||||
|
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||||
|
\ . ' -'
|
||||||
|
\}
|
||||||
|
endfunction
|
|
@ -2,6 +2,11 @@
|
||||||
ALE HCL Integration *ale-hcl-options*
|
ALE HCL Integration *ale-hcl-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
packer-fmt *ale-hcl-packer-fmt*
|
||||||
|
|
||||||
|
See |ale-packer-fmt-fixer| for information about the available options.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
terraform-fmt *ale-hcl-terraform-fmt*
|
terraform-fmt *ale-hcl-terraform-fmt*
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
===============================================================================
|
||||||
|
ALE Packer Integration *ale-packer-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
packer-fmt-fixer *ale-packer-fmt-fixer*
|
||||||
|
|
||||||
|
g:ale_packer_fmt_executable *g:ale_packer_fmt_executable*
|
||||||
|
*b:ale_packer_fmt_executable*
|
||||||
|
|
||||||
|
Type: |String|
|
||||||
|
Default: `'packer'`
|
||||||
|
|
||||||
|
This variable can be changed to use a different executable for packer.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_packer_fmt_options *g:ale_packer_fmt_options*
|
||||||
|
*b:ale_packer_fmt_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
|
@ -239,6 +239,7 @@ Notes:
|
||||||
* `stack-ghc`
|
* `stack-ghc`
|
||||||
* `stylish-haskell`
|
* `stylish-haskell`
|
||||||
* HCL
|
* HCL
|
||||||
|
* `packer-fmt`
|
||||||
* `terraform-fmt`
|
* `terraform-fmt`
|
||||||
* HTML
|
* HTML
|
||||||
* `VSCode HTML language server`
|
* `VSCode HTML language server`
|
||||||
|
@ -392,6 +393,8 @@ Notes:
|
||||||
* `ibm_validator`
|
* `ibm_validator`
|
||||||
* `prettier`
|
* `prettier`
|
||||||
* `yamllint`
|
* `yamllint`
|
||||||
|
* Packer
|
||||||
|
* `packer-fmt-fixer`
|
||||||
* Pascal
|
* Pascal
|
||||||
* `ptop`
|
* `ptop`
|
||||||
* Pawn
|
* Pawn
|
||||||
|
|
|
@ -2911,6 +2911,7 @@ documented in additional help files.
|
||||||
hie...................................|ale-haskell-hie|
|
hie...................................|ale-haskell-hie|
|
||||||
ormolu................................|ale-haskell-ormolu|
|
ormolu................................|ale-haskell-ormolu|
|
||||||
hcl.....................................|ale-hcl-options|
|
hcl.....................................|ale-hcl-options|
|
||||||
|
packer-fmt............................|ale-hcl-packer-fmt|
|
||||||
terraform-fmt.........................|ale-hcl-terraform-fmt|
|
terraform-fmt.........................|ale-hcl-terraform-fmt|
|
||||||
help....................................|ale-help-options|
|
help....................................|ale-help-options|
|
||||||
cspell................................|ale-help-cspell|
|
cspell................................|ale-help-cspell|
|
||||||
|
@ -3041,6 +3042,8 @@ documented in additional help files.
|
||||||
ibm_validator.........................|ale-openapi-ibm-validator|
|
ibm_validator.........................|ale-openapi-ibm-validator|
|
||||||
prettier..............................|ale-openapi-prettier|
|
prettier..............................|ale-openapi-prettier|
|
||||||
yamllint..............................|ale-openapi-yamllint|
|
yamllint..............................|ale-openapi-yamllint|
|
||||||
|
packer..................................|ale-packer-options|
|
||||||
|
packer-fmt-fixer......................|ale-packer-fmt-fixer|
|
||||||
pascal..................................|ale-pascal-options|
|
pascal..................................|ale-pascal-options|
|
||||||
ptop..................................|ale-pascal-ptop|
|
ptop..................................|ale-pascal-ptop|
|
||||||
pawn....................................|ale-pawn-options|
|
pawn....................................|ale-pawn-options|
|
||||||
|
|
|
@ -248,6 +248,7 @@ formatting.
|
||||||
* [stack-ghc](https://haskellstack.org/)
|
* [stack-ghc](https://haskellstack.org/)
|
||||||
* [stylish-haskell](https://github.com/jaspervdj/stylish-haskell)
|
* [stylish-haskell](https://github.com/jaspervdj/stylish-haskell)
|
||||||
* HCL
|
* HCL
|
||||||
|
* [packer-fmt](https://github.com/hashicorp/packer)
|
||||||
* [terraform-fmt](https://github.com/hashicorp/terraform)
|
* [terraform-fmt](https://github.com/hashicorp/terraform)
|
||||||
* HTML
|
* HTML
|
||||||
* [VSCode HTML language server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
* [VSCode HTML language server](https://github.com/hrsh7th/vscode-langservers-extracted)
|
||||||
|
@ -401,6 +402,8 @@ formatting.
|
||||||
* [ibm_validator](https://github.com/IBM/openapi-validator)
|
* [ibm_validator](https://github.com/IBM/openapi-validator)
|
||||||
* [prettier](https://github.com/prettier/prettier)
|
* [prettier](https://github.com/prettier/prettier)
|
||||||
* [yamllint](https://yamllint.readthedocs.io/)
|
* [yamllint](https://yamllint.readthedocs.io/)
|
||||||
|
* Packer (HCL)
|
||||||
|
* [packer-fmt-fixer](https://github.com/hashicorp/packer)
|
||||||
* Pascal
|
* Pascal
|
||||||
* [ptop](https://www.freepascal.org/tools/ptop.var)
|
* [ptop](https://www.freepascal.org/tools/ptop.var)
|
||||||
* Pawn
|
* Pawn
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
Before:
|
||||||
|
Save g:ale_packer_fmt_executable
|
||||||
|
Save g:ale_packer_fmt_options
|
||||||
|
|
||||||
|
" Use an invalid global executable, so we don't match it.
|
||||||
|
let g:ale_packer_fmt_executable = 'xxxinvalid'
|
||||||
|
let g:ale_packer_fmt_options = ''
|
||||||
|
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(The packer fmt callback should return the correct default values):
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('xxxinvalid') . ' fmt -',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#packer#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The packer fmt callback should include custom options):
|
||||||
|
let g:ale_packer_fmt_options = "-list=true"
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
|
\ . ' fmt'
|
||||||
|
\ . ' ' . g:ale_packer_fmt_options
|
||||||
|
\ . ' -',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#packer#Fix(bufnr(''))
|
Loading…
Reference in New Issue