summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorDerek P Sifford <dereksifford@gmail.com>2018-10-23 20:44:31 -0400
committerDerek P Sifford <dereksifford@gmail.com>2018-10-23 20:44:31 -0400
commite94a594e2ef65b27a79c406ce65c76a55fa39ead (patch)
tree3fe92d45eeb5c8613ddc7c11d141f84a5e411801 /autoload
parent2000436dfd7a25a8e9f66788c94bfb4512adda98 (diff)
downloadale-e94a594e2ef65b27a79c406ce65c76a55fa39ead.zip
add terraform fmt fixer for terraform and hcl filetypes
See #1718
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/terraform.vim17
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