parent
6e18c03d80
commit
2e323b529d
8 changed files with 75 additions and 0 deletions
|
@ -27,6 +27,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['python'],
|
||||
\ 'description': 'Fix PEP8 issues with black.',
|
||||
\ },
|
||||
\ 'dfmt': {
|
||||
\ 'function': 'ale#fixers#dfmt#Fix',
|
||||
\ 'suggested_filetypes': ['d'],
|
||||
\ 'description': 'Fix D files with dfmt.',
|
||||
\ },
|
||||
\ 'fecs': {
|
||||
\ 'function': 'ale#fixers#fecs#Fix',
|
||||
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
|
||||
|
|
18
autoload/ale/fixers/dfmt.vim
Normal file
18
autoload/ale/fixers/dfmt.vim
Normal file
|
@ -0,0 +1,18 @@
|
|||
" Author: theoldmoon0602
|
||||
" Description: Integration of dfmt with ALE.
|
||||
|
||||
call ale#Set('d_dfmt_executable', 'dfmt')
|
||||
call ale#Set('d_dfmt_options', '')
|
||||
|
||||
function! ale#fixers#dfmt#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'd_dfmt_executable')
|
||||
let l:options = ale#Var(a:buffer, 'd_dfmt_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' -i'
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options)
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
|
@ -1,6 +1,15 @@
|
|||
===============================================================================
|
||||
ALE D Integration *ale-d-options*
|
||||
|
||||
===============================================================================
|
||||
dfmt *ale-d-dfmt*
|
||||
|
||||
g:ale_d_dfmt_options *g:ale_d_dfmt_options*
|
||||
*b:ale_d_dfmt_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass additional options to the dfmt fixer.
|
||||
|
||||
===============================================================================
|
||||
dls *ale-d-dls*
|
||||
|
|
|
@ -103,6 +103,7 @@ Notes:
|
|||
* Cython (pyrex filetype)
|
||||
* `cython`
|
||||
* D
|
||||
* `dfmt`
|
||||
* `dls`
|
||||
* `dmd`
|
||||
* `uncrustify`
|
||||
|
|
|
@ -2066,6 +2066,7 @@ documented in additional help files.
|
|||
nvcc..................................|ale-cuda-nvcc|
|
||||
clang-format..........................|ale-cuda-clangformat|
|
||||
d.......................................|ale-d-options|
|
||||
dfmt..................................|ale-d-dfmt|
|
||||
dls...................................|ale-d-dls|
|
||||
uncrustify............................|ale-d-uncrustify|
|
||||
dart....................................|ale-dart-options|
|
||||
|
|
|
@ -112,6 +112,7 @@ formatting.
|
|||
* Cython (pyrex filetype)
|
||||
* [cython](http://cython.org/)
|
||||
* D
|
||||
* [dfmt](https://github.com/dlang-community/dfmt)
|
||||
* [dls](https://github.com/d-language-server/dls)
|
||||
* [dmd](https://dlang.org/dmd-linux.html)
|
||||
* [uncrustify](https://github.com/uncrustify/uncrustify)
|
||||
|
|
0
test/d_files/test.d
Normal file
0
test/d_files/test.d
Normal file
40
test/fixers/test_dfmt_fixer_callback.vader
Normal file
40
test/fixers/test_dfmt_fixer_callback.vader
Normal file
|
@ -0,0 +1,40 @@
|
|||
Before:
|
||||
Save g:ale_d_dfmt_executable
|
||||
Save g:ale_d_dfmt_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_d_dfmt_executable = 'xxxinvalid'
|
||||
let g:ale_d_dfmt_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The dfmt callback should return the correct default values):
|
||||
call ale#test#SetFilename('../d_files/test.d')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' -i'
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#dfmt#Fix(bufnr(''))
|
||||
|
||||
Execute(The dfmt callback should include custom dfmt options):
|
||||
let g:ale_d_dfmt_options = "--space-after-cast"
|
||||
call ale#test#SetFilename('../d_files/test.d')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' -i'
|
||||
\ . ' ' . g:ale_d_dfmt_options
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#dfmt#Fix(bufnr(''))
|
Reference in a new issue