diff options
author | Matheus Werny <46067952+Spixmaster@users.noreply.github.com> | 2023-08-15 11:15:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 10:15:06 +0100 |
commit | 951b280bd5665eadd00e22bef7c7ef23cdc57854 (patch) | |
tree | 7a719e2464e34bcd5ef6ac87465852f0818c7fef /autoload | |
parent | 15cbc0e912acf31d8185dbef00473e9555591350 (diff) | |
download | ale-951b280bd5665eadd00e22bef7c7ef23cdc57854.zip |
yamlfmt (#4587)
* Added the fixer, wrote tests and tested it
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 7 | ||||
-rw-r--r-- | autoload/ale/fixers/yamlfmt.vim | 20 |
2 files changed, 26 insertions, 1 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index a0e0c530..d2de0fc2 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -179,7 +179,12 @@ let s:default_registry = { \ 'yamlfix': { \ 'function': 'ale#fixers#yamlfix#Fix', \ 'suggested_filetypes': ['yaml'], -\ 'description': 'Fix yaml files with yamlfix.', +\ 'description': 'Fix YAML files with yamlfix.', +\ }, +\ 'yamlfmt': { +\ 'function': 'ale#fixers#yamlfmt#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Format YAML files with yamlfmt.', \ }, \ 'yapf': { \ 'function': 'ale#fixers#yapf#Fix', diff --git a/autoload/ale/fixers/yamlfmt.vim b/autoload/ale/fixers/yamlfmt.vim new file mode 100644 index 00000000..e730832a --- /dev/null +++ b/autoload/ale/fixers/yamlfmt.vim @@ -0,0 +1,20 @@ +" Author: https://github.com/Spixmaster +" Description: Format YAML files with yamlfmt. + +call ale#Set('yaml_yamlfmt_executable', 'yamlfmt') +call ale#Set('yaml_yamlfmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('yaml_yamlfmt_options', '') + +function! ale#fixers#yamlfmt#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'yaml_yamlfmt', + \ ['yamlfmt'] + \) + + let l:options = ale#Var(a:buffer, 'yaml_yamlfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -in', + \} +endfunction |