diff options
author | Horacio Sanson <hsanson@gmail.com> | 2021-02-05 22:58:43 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 22:58:43 +0900 |
commit | f6128058013e9df6191c54e5d985153a86a215c0 (patch) | |
tree | 4e69ea2a079a0ad75aec97a65c2369bede69d0ab | |
parent | 9b5c09047361f3ec2cf18afbb6d1e03047a59778 (diff) | |
parent | a49f664aea742bafae43af50eac568143870a663 (diff) | |
download | ale-f6128058013e9df6191c54e5d985153a86a215c0.zip |
Merge pull request #3576 from cyyever/fish_indent
Fish indent
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/fish_indent.vim | 19 | ||||
-rw-r--r-- | doc/ale-fish.txt | 17 | ||||
-rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 1 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | supported-tools.md | 1 | ||||
-rw-r--r-- | test/fish_files/testfile.fish | 0 | ||||
-rw-r--r-- | test/fixers/test_fish_indent_fixer_callback.vader | 40 |
8 files changed, 84 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index a591a57b..23441ca5 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -216,6 +216,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['cmake'], \ 'description': 'Fix CMake files with cmake-format.', \ }, +\ 'fish_indent': { +\ 'function': 'ale#fixers#fish_indent#Fix', +\ 'suggested_filetypes': ['fish'], +\ 'description': 'Format fish scripts using fish_indent.', +\ }, \ 'gofmt': { \ 'function': 'ale#fixers#gofmt#Fix', \ 'suggested_filetypes': ['go'], diff --git a/autoload/ale/fixers/fish_indent.vim b/autoload/ale/fixers/fish_indent.vim new file mode 100644 index 00000000..ebf17c5a --- /dev/null +++ b/autoload/ale/fixers/fish_indent.vim @@ -0,0 +1,19 @@ +" Author: Chen YuanYuan <cyyever@outlook.com> +" Description: Integration of fish_indent with ALE. + +call ale#Set('fish_fish_indent_executable', 'fish_indent') +call ale#Set('fish_fish_indent_options', '') + +function! ale#fixers#fish_indent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'fish_fish_indent_executable') + let l:options = ale#Var(a:buffer, 'fish_fish_indent_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w ' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/doc/ale-fish.txt b/doc/ale-fish.txt index 8450b38a..7dbbc10c 100644 --- a/doc/ale-fish.txt +++ b/doc/ale-fish.txt @@ -11,4 +11,21 @@ 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_indent *ale-fish-fish_indent* + +g:ale_fish_fish_indent_executable *g:ale_fish_fish_indent_executable* + *b:ale_fish_fish_indent_executable* + Type: |String| + Default: `'fish_indent'` + + This variable can be changed to use a different executable for fish_indent. + +g:ale_fish_fish_indent_options *g:ale_fish_fish_indent_options* + *b:ale_fish_fish_indent_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: diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 72c685c5..33771e49 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -152,6 +152,7 @@ Notes: * `erlc` * Fish * `fish` (-n flag) + * `fish_indent` * Fortran * `gcc` * `language_server` diff --git a/doc/ale.txt b/doc/ale.txt index 9268c9f2..034d62b8 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2699,6 +2699,7 @@ documented in additional help files. eruby...................................|ale-eruby-options| ruumba................................|ale-eruby-ruumba| fish....................................|ale-fish-options| + fish_indent...........................|ale-fish-fish_indent| fortran.................................|ale-fortran-options| gcc...................................|ale-fortran-gcc| language_server.......................|ale-fortran-language-server| diff --git a/supported-tools.md b/supported-tools.md index e449ff39..b649ec22 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -161,6 +161,7 @@ formatting. * [erlc](http://erlang.org/doc/man/erlc.html) * Fish * fish [-n flag](https://linux.die.net/man/1/fish) + * [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) * Fortran * [gcc](https://gcc.gnu.org/) * [language_server](https://github.com/hansec/fortran-language-server) diff --git a/test/fish_files/testfile.fish b/test/fish_files/testfile.fish new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fish_files/testfile.fish diff --git a/test/fixers/test_fish_indent_fixer_callback.vader b/test/fixers/test_fish_indent_fixer_callback.vader new file mode 100644 index 00000000..beb0b42e --- /dev/null +++ b/test/fixers/test_fish_indent_fixer_callback.vader @@ -0,0 +1,40 @@ +Before: + Save g:ale_fish_fish_indent_executable + Save g:ale_fish_fish_indent_options + + " Use an invalid global executable, so we don't match it. + let g:ale_fish_fish_indent_executable = 'xxxinvalid' + let g:ale_fish_fish_indent_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_fish_indent_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('')) |