add doc and test
This commit is contained in:
parent
983c7e8805
commit
9d1a71a5cb
8 changed files with 65 additions and 5 deletions
|
@ -183,7 +183,7 @@ let s:default_registry = {
|
||||||
\ 'fish_indent': {
|
\ 'fish_indent': {
|
||||||
\ 'function': 'ale#fixers#fish_indent#Fix',
|
\ 'function': 'ale#fixers#fish_indent#Fix',
|
||||||
\ 'suggested_filetypes': ['fish'],
|
\ 'suggested_filetypes': ['fish'],
|
||||||
\ 'description': 'Fix fish shell scripts with fish_indent.',
|
\ 'description': 'Format fish scripts using fish_indent.',
|
||||||
\ },
|
\ },
|
||||||
\ 'gofmt': {
|
\ 'gofmt': {
|
||||||
\ 'function': 'ale#fixers#gofmt#Fix',
|
\ 'function': 'ale#fixers#gofmt#Fix',
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
" Author: Chen YuanYuan <cyyever@outlook.com>
|
" Author: Chen YuanYuan <cyyever@outlook.com>
|
||||||
" Description: Integration of fish_indent with ALE.
|
" Description: Integration of fish_indent with ALE.
|
||||||
|
|
||||||
call ale#Set('fish_indent_executable', 'fish_indent')
|
call ale#Set('fish_fishindent_executable', 'fish_indent')
|
||||||
call ale#Set('fish_indent_options', '')
|
call ale#Set('fish_fishindent_options', '')
|
||||||
|
|
||||||
function! ale#fixers#fish_indent#Fix(buffer) abort
|
function! ale#fixers#fish_indent#Fix(buffer) abort
|
||||||
let l:executable = ale#Var(a:buffer, 'fish_indent_executable')
|
let l:executable = ale#Var(a:buffer, 'fish_fishindent_executable')
|
||||||
let l:options = ale#Var(a:buffer, 'fish_indent_options')
|
let l:options = ale#Var(a:buffer, 'fish_fishindent_options')
|
||||||
let l:filename = ale#Escape(bufname(a:buffer))
|
let l:filename = ale#Escape(bufname(a:buffer))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -10,5 +10,22 @@ displaying errors if an error message is not found.
|
||||||
If ALE is not showing any errors but your file does not run as expected, run
|
If ALE is not showing any errors but your file does not run as expected, run
|
||||||
`fish -n <file.fish>` from the command line.
|
`fish -n <file.fish>` from the command line.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
fish_indent *ale-fish-fishindent*
|
||||||
|
|
||||||
|
g:ale_fish_fishindent_executable *g:ale_fish_fishindent_executable*
|
||||||
|
*b:ale_fish_fishindent_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'fish_indent'`
|
||||||
|
|
||||||
|
This variable can be changed to use a different executable for fish_indent.
|
||||||
|
|
||||||
|
g:ale_fish_fishindent_options *g:ale_fish_fishindent_options*
|
||||||
|
*b:ale_fish_fishindent_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to fish_indent.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -144,6 +144,7 @@ Notes:
|
||||||
* `SyntaxErl`
|
* `SyntaxErl`
|
||||||
* Fish
|
* Fish
|
||||||
* `fish` (-n flag)
|
* `fish` (-n flag)
|
||||||
|
* `fish_indent`
|
||||||
* Fortran
|
* Fortran
|
||||||
* `gcc`
|
* `gcc`
|
||||||
* `language_server`
|
* `language_server`
|
||||||
|
|
|
@ -2594,6 +2594,7 @@ documented in additional help files.
|
||||||
eruby...................................|ale-eruby-options|
|
eruby...................................|ale-eruby-options|
|
||||||
ruumba................................|ale-eruby-ruumba|
|
ruumba................................|ale-eruby-ruumba|
|
||||||
fish....................................|ale-fish-options|
|
fish....................................|ale-fish-options|
|
||||||
|
fish_indent...........................|ale-fish-fishindent|
|
||||||
fortran.................................|ale-fortran-options|
|
fortran.................................|ale-fortran-options|
|
||||||
gcc...................................|ale-fortran-gcc|
|
gcc...................................|ale-fortran-gcc|
|
||||||
language_server.......................|ale-fortran-language-server|
|
language_server.......................|ale-fortran-language-server|
|
||||||
|
|
|
@ -153,6 +153,7 @@ formatting.
|
||||||
* [SyntaxErl](https://github.com/ten0s/syntaxerl)
|
* [SyntaxErl](https://github.com/ten0s/syntaxerl)
|
||||||
* Fish
|
* Fish
|
||||||
* fish [-n flag](https://linux.die.net/man/1/fish)
|
* fish [-n flag](https://linux.die.net/man/1/fish)
|
||||||
|
* [fish_indent](https://linux.die.net/man/1/fish_indent)
|
||||||
* Fortran
|
* Fortran
|
||||||
* [gcc](https://gcc.gnu.org/)
|
* [gcc](https://gcc.gnu.org/)
|
||||||
* [language_server](https://github.com/hansec/fortran-language-server)
|
* [language_server](https://github.com/hansec/fortran-language-server)
|
||||||
|
|
0
test/fish_files/testfile.fish
Normal file
0
test/fish_files/testfile.fish
Normal file
40
test/fixers/test_fish_indent_fixer_callback.vader
Normal file
40
test/fixers/test_fish_indent_fixer_callback.vader
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
Before:
|
||||||
|
Save g:ale_fish_fishindent_executable
|
||||||
|
Save g:ale_fish_fishindent_options
|
||||||
|
|
||||||
|
" Use an invalid global executable, so we don't match it.
|
||||||
|
let g:ale_fish_fishindent_executable = 'xxxinvalid'
|
||||||
|
let g:ale_fish_fishindent_options = ''
|
||||||
|
|
||||||
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
|
Execute(The fish_indent callback should return the correct default values):
|
||||||
|
call ale#test#SetFilename('../fish_files/testfile.fish')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
|
\ . ' -w '
|
||||||
|
\ . ' %t',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#fish_indent#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The fish_indent callback should include custom fish_indent options):
|
||||||
|
let g:ale_fish_fishindent_options = "-d"
|
||||||
|
call ale#test#SetFilename('../fish_files/testfile.fish')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
|
\ . ' -w '
|
||||||
|
\ . ' -d'
|
||||||
|
\ . ' %t',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#fish_indent#Fix(bufnr(''))
|
Reference in a new issue