* Added the fixer, wrote tests and tested it
This commit is contained in:
Matheus Werny 2023-08-15 11:15:06 +02:00 committed by GitHub
parent 15cbc0e912
commit 951b280bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 80 additions and 1 deletions

View File

@ -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',

View File

@ -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

View File

@ -699,6 +699,7 @@ Notes:
* `swaglint`
* `yaml-language-server`
* `yamlfix`
* `yamlfmt`
* `yamllint`
* YANG
* `yang-lsp`

View File

@ -47,6 +47,7 @@ g:ale_yaml_actionlint_options *g:ale_yaml_actionlint_options*
<
Please note that passing `-format` as option is not supported at the moment.
===============================================================================
circleci *ale-yaml-circleci*
@ -242,6 +243,44 @@ g:ale_yaml_yamlfix_use_global *g:ale_yaml_yamlfix_use_global*
See |ale-integrations-local-executables|
===============================================================================
yamlfmt *ale-yaml-yamlfmt*
Website: https://github.com/google/yamlfmt
Installation
-------------------------------------------------------------------------------
Install yamlfmt:
See the website.
Options
-------------------------------------------------------------------------------
g:ale_yaml_yamlfmt_executable *g:ale_yaml_yamlfmt_executable*
*b:ale_yaml_yamlfmt_executable*
Type: |String|
Default: `'yamlfmt'`
See |ale-integrations-local-executables|
g:ale_yaml_yamlfmt_options *g:ale_yaml_yamlfmt_options*
*b:ale_yaml_yamlfmt_options*
Type: |String|
Default: `''`
This variable can be set to pass extra options to yamlfmt.
g:ale_yaml_yamlfmt_use_global *g:ale_yaml_yamlfmt_use_global*
*b:ale_yaml_yamlfmt_use_global*
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
yamllint *ale-yaml-yamllint*

View File

@ -3427,6 +3427,7 @@ documented in additional help files.
swaglint..............................|ale-yaml-swaglint|
yaml-language-server..................|ale-yaml-language-server|
yamlfix...............................|ale-yaml-yamlfix|
yamlfmt...............................|ale-yaml-yamlfmt|
yamllint..............................|ale-yaml-yamllint|
gitlablint............................|ale-yaml-gitlablint|
yang....................................|ale-yang-options|

View File

@ -708,6 +708,7 @@ formatting.
* [swaglint](https://github.com/byCedric/swaglint) :warning:
* [yaml-language-server](https://github.com/redhat-developer/yaml-language-server)
* [yamlfix](https://lyz-code.github.io/yamlfix)
* [yamlfmt](https://github.com/google/yamlfmt)
* [yamllint](https://yamllint.readthedocs.io/)
* YANG
* [yang-lsp](https://github.com/theia-ide/yang-lsp)

View File

@ -0,0 +1,12 @@
Before:
call ale#assert#SetUpFixerTest('yaml', 'yamlfmt')
After:
Restore
call ale#assert#TearDownFixerTest()
Execute(The yamlfmt callback should return the correct default command):
AssertEqual
\ {'command': ale#Escape('yamlfmt') . ' -in'},
\ ale#fixers#yamlfmt#Fix(bufnr(''))