mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-25 02:57:20 +08:00
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:
@@ -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'],
|
||||
|
||||
17
autoload/ale/fixers/packer.vim
Normal file
17
autoload/ale/fixers/packer.vim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user