commit
755f1a4ccf
8 changed files with 68 additions and 0 deletions
|
@ -22,6 +22,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Fix PEP8 issues with black.',
|
||||
\ },
|
||||
\ 'tidy': {
|
||||
\ 'function': 'ale#fixers#tidy#Fix',
|
||||
\ 'suggested_filetypes': ['html'],
|
||||
\ 'description': 'Fix HTML files with tidy.',
|
||||
\ },
|
||||
\ 'prettier_standard': {
|
||||
\ 'function': 'ale#fixers#prettier_standard#Fix',
|
||||
\ 'suggested_filetypes': ['javascript'],
|
||||
|
|
26
autoload/ale/fixers/tidy.vim
Normal file
26
autoload/ale/fixers/tidy.vim
Normal file
|
@ -0,0 +1,26 @@
|
|||
" Author: meain <abinsimon10@gmail.com>
|
||||
" Description: Fixing HTML files with tidy.
|
||||
|
||||
call ale#Set('html_tidy_executable', 'tidy')
|
||||
call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale#fixers#tidy#Fix(buffer) abort
|
||||
let l:executable = ale#node#FindExecutable(
|
||||
\ a:buffer,
|
||||
\ 'html_tidy',
|
||||
\ ['tidy'],
|
||||
\)
|
||||
|
||||
if !executable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, '.tidyrc')
|
||||
let l:config_options = !empty(l:config)
|
||||
\ ? ' -q --tidy-mark no --show-errors 0 --show-warnings 0 -config ' . ale#Escape(l:config)
|
||||
\ : ' -q --tidy-mark no --show-errors 0 --show-warnings 0'
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable) . l:config_options,
|
||||
\}
|
||||
endfunction
|
|
@ -71,6 +71,14 @@ g:ale_html_tidy_options *g:ale_html_tidy_options*
|
|||
(mac), sjis (shiftjis), utf-16le, utf-16, utf-8
|
||||
|
||||
|
||||
g:ale_html_tidy_use_global *g:html_tidy_use_global*
|
||||
|
||||
Type: |Number|
|
||||
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
===============================================================================
|
||||
write-good *ale-html-write-good*
|
||||
|
||||
|
|
0
test/command_callback/tidy_paths/.tidyrc
Normal file
0
test/command_callback/tidy_paths/.tidyrc
Normal file
0
test/command_callback/tidy_paths/test.html
Normal file
0
test/command_callback/tidy_paths/test.html
Normal file
0
test/command_callback/tidy_paths/tidy
Executable file
0
test/command_callback/tidy_paths/tidy
Executable file
0
test/command_callback/tidy_paths/tidy.exe
Executable file
0
test/command_callback/tidy_paths/tidy.exe
Executable file
29
test/fixers/test_tidy_fixer_callback.vader
Normal file
29
test/fixers/test_tidy_fixer_callback.vader
Normal file
|
@ -0,0 +1,29 @@
|
|||
Before:
|
||||
Save g:ale_html_tidy_executable
|
||||
|
||||
let g:ale_html_tidy_executable = 'tidy_paths/tidy'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The tidy callback should return 0 if tidy not found):
|
||||
let g:ale_html_tidy_executable = 'xxxinvalidpath'
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#fixers#tidy#Fix(bufnr(''))
|
||||
|
||||
Execute(The tidy callback should return the correct default command):
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('tidy_paths/tidy')
|
||||
\ . ' -q --tidy-mark no --show-errors 0 --show-warnings 0'
|
||||
\ },
|
||||
\ ale#fixers#tidy#Fix(bufnr(''))
|
Reference in a new issue