summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/packer.vim17
2 files changed, 22 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 6932ad9d..eae29000 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -436,6 +436,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['hcl', 'terraform'],
\ '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': {
\ 'function': 'ale#fixers#crystal#Fix',
\ 'suggested_filetypes': ['cr'],
diff --git a/autoload/ale/fixers/packer.vim b/autoload/ale/fixers/packer.vim
new file mode 100644
index 00000000..8770550d
--- /dev/null
+++ b/autoload/ale/fixers/packer.vim
@@ -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