mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 13:02:28 +08:00
Merge pull request #1866 from Steap/feature/xmllint-fixer
Add support for xmllint as a fixer.
This commit is contained in:
@@ -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.
|
||||
|
||||
27
autoload/ale/fixers/xmllint.vim
Normal file
27
autoload/ale/fixers/xmllint.vim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user