diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-10-25 14:05:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-25 14:05:48 +0100 |
commit | 68b55912990226003213c25e43a57847ac7f36f1 (patch) | |
tree | 4ee62e09f83cd92622037f9730661fffd12f52b5 /autoload | |
parent | 2000436dfd7a25a8e9f66788c94bfb4512adda98 (diff) | |
parent | 395cabc22a2ffd71ab0ed288d9de8651afacfbf1 (diff) | |
download | ale-68b55912990226003213c25e43a57847ac7f36f1.zip |
Merge pull request #2015 from dsifford/dsifford-terraform
add terraform fmt fixer for terraform and hcl filetypes
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/terraform.vim | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 76cce87f..98f52232 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -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. diff --git a/autoload/ale/fixers/terraform.vim b/autoload/ale/fixers/terraform.vim new file mode 100644 index 00000000..bc05380a --- /dev/null +++ b/autoload/ale/fixers/terraform.vim @@ -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 |