mirror of
https://github.com/dense-analysis/ale
synced 2024-12-11 17:06:52 +00:00
parent
15cbc0e912
commit
951b280bd5
@ -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',
|
||||
|
20
autoload/ale/fixers/yamlfmt.vim
Normal file
20
autoload/ale/fixers/yamlfmt.vim
Normal 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
|
@ -699,6 +699,7 @@ Notes:
|
||||
* `swaglint`
|
||||
* `yaml-language-server`
|
||||
* `yamlfix`
|
||||
* `yamlfmt`
|
||||
* `yamllint`
|
||||
* YANG
|
||||
* `yang-lsp`
|
||||
|
@ -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*
|
||||
|
||||
|
@ -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|
|
||||
|
@ -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)
|
||||
|
12
test/fixers/test_yamlfmt_fixer_callback.vader
Normal file
12
test/fixers/test_yamlfmt_fixer_callback.vader
Normal 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(''))
|
Loading…
Reference in New Issue
Block a user