2017-11-05 16:24:41 -05:00
|
|
|
Before:
|
|
|
|
Save g:ale_sh_shfmt_executable
|
|
|
|
Save g:ale_sh_shfmt_options
|
2018-09-18 02:41:33 -04:00
|
|
|
Save &l:expandtab
|
|
|
|
Save &l:shiftwidth
|
|
|
|
Save &l:tabstop
|
2017-11-05 16:24:41 -05:00
|
|
|
|
2017-11-05 16:31:41 -05:00
|
|
|
After:
|
|
|
|
Restore
|
2017-11-05 16:24:41 -05:00
|
|
|
|
2018-09-18 02:41:33 -04:00
|
|
|
Execute(The shfmt callback should return 'shfmt' as default command):
|
|
|
|
setlocal noexpandtab
|
|
|
|
Assert
|
|
|
|
\ ale#fixers#shfmt#Fix(bufnr('')).command =~# '^' . ale#Escape('shfmt'),
|
|
|
|
\ "Default command name is expected to be 'shfmt'"
|
|
|
|
|
|
|
|
Execute(The shfmt callback should return the command with no option as default when noexpandtab is set):
|
|
|
|
let g:ale_sh_shfmt_executable = 'shfmt'
|
|
|
|
let g:ale_sh_shfmt_options = ''
|
|
|
|
setlocal noexpandtab
|
2017-11-05 16:24:41 -05:00
|
|
|
AssertEqual
|
|
|
|
\ {
|
2017-11-05 16:31:41 -05:00
|
|
|
\ 'command': ale#Escape('shfmt'),
|
2017-11-05 16:24:41 -05:00
|
|
|
\ },
|
|
|
|
\ ale#fixers#shfmt#Fix(bufnr(''))
|
|
|
|
|
2018-09-18 02:41:33 -04:00
|
|
|
Execute(The shfmt callback should return the command specifying indent width by looking shiftwidth as default):
|
|
|
|
let g:ale_sh_shfmt_executable = 'shfmt'
|
|
|
|
let g:ale_sh_shfmt_options = ''
|
|
|
|
setlocal expandtab
|
|
|
|
setlocal shiftwidth=4
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'command': ale#Escape('shfmt') . ' -i 4',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#shfmt#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The shfmt callback should return the command specifying indent width by looking tabstop when shiftwidth is 0 as default):
|
|
|
|
let g:ale_sh_shfmt_executable = 'shfmt'
|
|
|
|
let g:ale_sh_shfmt_options = ''
|
|
|
|
setlocal expandtab
|
|
|
|
setlocal shiftwidth=0
|
|
|
|
setlocal tabstop=8
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'command': ale#Escape('shfmt') . ' -i 8',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#shfmt#Fix(bufnr(''))
|
|
|
|
|
2017-11-05 16:31:41 -05:00
|
|
|
Execute(The shfmt executable and options should be configurable):
|
|
|
|
let g:ale_sh_shfmt_executable = 'foobar'
|
2017-11-05 16:24:41 -05:00
|
|
|
let g:ale_sh_shfmt_options = '--some-option'
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
2017-11-05 16:31:41 -05:00
|
|
|
\ 'command': ale#Escape('foobar')
|
2017-11-05 16:24:41 -05:00
|
|
|
\ . ' --some-option',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#shfmt#Fix(bufnr(''))
|