diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-08-28 23:36:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-28 23:36:00 +0100 |
commit | ee3142b6016895b42840f6ba1a847672b410ae6e (patch) | |
tree | 9d97cc6dd8485345459a0f0aec3237b6c9b9d46b /autoload | |
parent | 79f02fce69a0dceb8bbbe2c6f5a7cebceaa34be6 (diff) | |
parent | cc5ad6491f2b2c3bbd10e236b5b414e92464e6b7 (diff) | |
download | ale-ee3142b6016895b42840f6ba1a847672b410ae6e.zip |
Merge pull request #1866 from Steap/feature/xmllint-fixer
Add support for xmllint as a fixer.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/xmllint.vim | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index ead4e058..1ca54a86 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -230,6 +230,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['dart'], \ 'description': 'Fix Dart files with dartfmt.', \ }, +\ 'xmllint': { +\ 'function': 'ale#fixers#xmllint#Fix', +\ 'suggested_filetypes': ['xml'], +\ 'description': 'Fix XML files with xmllint.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/xmllint.vim b/autoload/ale/fixers/xmllint.vim new file mode 100644 index 00000000..9beaa48c --- /dev/null +++ b/autoload/ale/fixers/xmllint.vim @@ -0,0 +1,27 @@ +" Author: Cyril Roelandt <tipecaml@gmail.com> +" Description: Integration of xmllint with ALE. + +call ale#Set('xml_xmllint_executable', 'xmllint') +call ale#Set('xml_xmllint_options', '') +call ale#Set('xml_xmllint_indentsize', 2) + +function! ale#fixers#xmllint#Fix(buffer) abort + let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable')) + let l:filename = ale#Escape(bufname(a:buffer)) + let l:command = l:executable . ' --format ' . l:filename + + let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize') + if l:indent isnot# '' + let l:env = ale#Env('XMLLINT_INDENT', repeat(' ', l:indent)) + let l:command = l:env . l:command + endif + + let l:options = ale#Var(a:buffer, 'xml_xmllint_options') + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return { + \ 'command': l:command + \} +endfunction |