mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-11 09:08:32 +08:00
Support format xml file which haven't yet persisted at the disk (#4585)
Support format xml file which haven't yet persisted at the disk
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
" Author: Cyril Roelandt <tipecaml@gmail.com>
|
" Author: Cyril Roelandt <tipecaml@gmail.com>, jiz4oh <me@jiz4oh.com>
|
||||||
" Description: Integration of xmllint with ALE.
|
" Description: Integration of xmllint with ALE.
|
||||||
|
|
||||||
call ale#Set('xml_xmllint_executable', 'xmllint')
|
call ale#Set('xml_xmllint_executable', 'xmllint')
|
||||||
@@ -7,7 +7,14 @@ call ale#Set('xml_xmllint_indentsize', 2)
|
|||||||
|
|
||||||
function! ale#fixers#xmllint#Fix(buffer) abort
|
function! ale#fixers#xmllint#Fix(buffer) abort
|
||||||
let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable'))
|
let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable'))
|
||||||
let l:filename = ale#Escape(bufname(a:buffer))
|
let l:filename = bufname(a:buffer)
|
||||||
|
|
||||||
|
if empty(l:filename)
|
||||||
|
let l:filename = '%t'
|
||||||
|
else
|
||||||
|
let l:filename = ale#Escape(l:filename)
|
||||||
|
endif
|
||||||
|
|
||||||
let l:command = l:executable . ' --format ' . l:filename
|
let l:command = l:executable . ' --format ' . l:filename
|
||||||
|
|
||||||
let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize')
|
let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize')
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ Before:
|
|||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
Execute(The xmllint callback should return the correct default command with unpersisted buffer):
|
||||||
|
new
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('/path/to/xmllint')
|
||||||
|
\ . ' --format %t'
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#xmllint#Fix(bufnr(''))
|
||||||
|
|
||||||
Execute(The xmllint callback should return the correct default command):
|
Execute(The xmllint callback should return the correct default command):
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
|
|||||||
Reference in New Issue
Block a user