mirror of https://github.com/dense-analysis/ale
parent
2000436dfd
commit
e94a594e2e
|
@ -250,6 +250,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['c', 'cpp', 'cs', 'objc', 'objcpp', 'd', 'java', 'p', 'vala' ],
|
||||
\ 'description': 'Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.',
|
||||
\ },
|
||||
\ 'terraform': {
|
||||
\ 'function': 'ale#fixers#terraform#Fix',
|
||||
\ 'suggested_filetypes': ['hcl', 'terraform'],
|
||||
\ 'description': 'Fix tf and hcl files with terraform fmt.',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
" Author: dsifford <dereksifford@gmail.com>
|
||||
" Description: Fixer for terraform and .hcl files
|
||||
|
||||
call ale#Set('terraform_fmt_executable', 'terraform')
|
||||
call ale#Set('terraform_fmt_options', '')
|
||||
|
||||
function! ale#fixers#terraform#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'terraform_fmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'terraform_fmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' fmt'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' -'
|
||||
\}
|
||||
endfunction
|
|
@ -0,0 +1,11 @@
|
|||
===============================================================================
|
||||
ALE HCL Integration *ale-hcl-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
terraform-fmt *ale-hcl-terraform-fmt*
|
||||
|
||||
See |ale-terraform-fmt| for information about the available options.
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
|
@ -2,6 +2,24 @@
|
|||
ALE Terraform Integration *ale-terraform-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
fmt *ale-terraform-fmt*
|
||||
|
||||
g:ale_terraform_fmt_executable *g:ale_terraform_fmt_executable*
|
||||
*b:ale_terraform_fmt_executable*
|
||||
|
||||
Type: |String|
|
||||
Default: `'terraform'`
|
||||
|
||||
This variable can be changed to use a different executable for terraform.
|
||||
|
||||
|
||||
g:ale_terraform_fmt_options *g:ale_terraform_fmt_options*
|
||||
*b:ale_terraform_fmt_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
|
||||
===============================================================================
|
||||
tflint *ale-terraform-tflint*
|
||||
|
||||
|
|
|
@ -129,6 +129,8 @@ CONTENTS *ale-contents*
|
|||
stack-build.........................|ale-haskell-stack-build|
|
||||
stylish-haskell.....................|ale-haskell-stylish-haskell|
|
||||
hie.................................|ale-haskell-hie|
|
||||
hcl...................................|ale-hcl-options|
|
||||
terraform-fmt.......................|ale-hcl-terraform-fmt|
|
||||
html..................................|ale-html-options|
|
||||
htmlhint............................|ale-html-htmlhint|
|
||||
tidy................................|ale-html-tidy|
|
||||
|
@ -297,6 +299,7 @@ CONTENTS *ale-contents*
|
|||
tcl...................................|ale-tcl-options|
|
||||
nagelfar............................|ale-tcl-nagelfar|
|
||||
terraform.............................|ale-terraform-options|
|
||||
fmt.................................|ale-terraform-fmt|
|
||||
tflint..............................|ale-terraform-tflint|
|
||||
tex...................................|ale-tex-options|
|
||||
chktex..............................|ale-tex-chktex|
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
Before:
|
||||
Save g:ale_terraform_fmt_executable
|
||||
Save g:ale_terraform_fmt_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_terraform_fmt_executable = 'xxxinvalid'
|
||||
let g:ale_terraform_fmt_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The terraform fmt callback should return the correct default values):
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid') . ' fmt -',
|
||||
\ },
|
||||
\ ale#fixers#terraform#Fix(bufnr(''))
|
||||
|
||||
Execute(The terraform fmt callback should include custom options):
|
||||
let g:ale_terraform_fmt_options = "-list=true"
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' fmt'
|
||||
\ . ' ' . g:ale_terraform_fmt_options
|
||||
\ . ' -',
|
||||
\ },
|
||||
\ ale#fixers#terraform#Fix(bufnr(''))
|
Loading…
Reference in New Issue