summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2020-11-27 16:02:33 +0900
committerGitHub <noreply@github.com>2020-11-27 16:02:33 +0900
commit1365dce921c1fb84a668ae121d5d5aeebef99fbc (patch)
treea8de9ed73e87ad1b0ea0f997c7701ee237f9a259 /autoload
parent681a6e371d02cce9c2414c19f5deeae61aa321fa (diff)
parent12eb8d15234e6f4e77672c29659c29a7c0dcf2fb (diff)
downloadale-1365dce921c1fb84a668ae121d5d5aeebef99fbc.zip
Merge pull request #3461 from lyz-code/feat/add-yamlfixer
feat: add yamlfix fixer
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/yamlfix.vim25
2 files changed, 30 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 3a88ede1..0f146faa 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -110,6 +110,11 @@ let s:default_registry = {
\ 'suggested_filetypes': [],
\ 'description': 'Remove all trailing whitespace characters at the end of every line.',
\ },
+\ 'yamlfix': {
+\ 'function': 'ale#fixers#yamlfix#Fix',
+\ 'suggested_filetypes': ['yaml'],
+\ 'description': 'Fix yaml files with yamlfix.',
+\ },
\ 'yapf': {
\ 'function': 'ale#fixers#yapf#Fix',
\ 'suggested_filetypes': ['python'],
diff --git a/autoload/ale/fixers/yamlfix.vim b/autoload/ale/fixers/yamlfix.vim
new file mode 100644
index 00000000..966556c9
--- /dev/null
+++ b/autoload/ale/fixers/yamlfix.vim
@@ -0,0 +1,25 @@
+" Author: lyz-code
+" Description: Fixing yaml files with yamlfix.
+
+call ale#Set('yaml_yamlfix_executable', 'yamlfix')
+call ale#Set('yaml_yamlfix_options', '')
+call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale#fixers#yamlfix#Fix(buffer) abort
+ let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options')
+
+ let l:executable = ale#python#FindExecutable(
+ \ a:buffer,
+ \ 'yaml_yamlfix',
+ \ ['yamlfix'],
+ \)
+
+ if !executable(l:executable)
+ return 0
+ endif
+
+ return {
+ \ 'command': ale#path#BufferCdString(a:buffer)
+ \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
+ \}
+endfunction