From 983c7e880523de3b18e42f1405ba2d3ba6509960 Mon Sep 17 00:00:00 2001 From: cyy Date: Sun, 25 Aug 2019 22:14:53 +0800 Subject: add fish_indent fixer --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/fish_indent.vim | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 autoload/ale/fixers/fish_indent.vim diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index d71668f2..ed3339c9 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -180,6 +180,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': 'Fix fish shell scripts with 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..215a14ec --- /dev/null +++ b/autoload/ale/fixers/fish_indent.vim @@ -0,0 +1,19 @@ +" Author: Chen YuanYuan +" Description: Integration of fish_indent with ALE. + +call ale#Set('fish_indent_executable', 'fish_indent') +call ale#Set('fish_indent_options', '') + +function! ale#fixers#fish_indent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'fish_indent_executable') + let l:options = ale#Var(a:buffer, '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 -- cgit v1.2.3 From 9d1a71a5cb7473e34f7ae27162de4538dbeb9cb8 Mon Sep 17 00:00:00 2001 From: cyy Date: Mon, 23 Sep 2019 10:43:31 +0800 Subject: add doc and test --- autoload/ale/fix/registry.vim | 2 +- autoload/ale/fixers/fish_indent.vim | 8 ++--- doc/ale-fish.txt | 17 ++++++++++ doc/ale-supported-languages-and-tools.txt | 1 + doc/ale.txt | 1 + supported-tools.md | 1 + test/fish_files/testfile.fish | 0 test/fixers/test_fish_indent_fixer_callback.vader | 40 +++++++++++++++++++++++ 8 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 test/fish_files/testfile.fish create mode 100644 test/fixers/test_fish_indent_fixer_callback.vader diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index ed3339c9..f8c04aef 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -183,7 +183,7 @@ let s:default_registry = { \ 'fish_indent': { \ 'function': 'ale#fixers#fish_indent#Fix', \ 'suggested_filetypes': ['fish'], -\ 'description': 'Fix fish shell scripts with fish_indent.', +\ 'description': 'Format fish scripts using fish_indent.', \ }, \ 'gofmt': { \ 'function': 'ale#fixers#gofmt#Fix', diff --git a/autoload/ale/fixers/fish_indent.vim b/autoload/ale/fixers/fish_indent.vim index 215a14ec..98572e47 100644 --- a/autoload/ale/fixers/fish_indent.vim +++ b/autoload/ale/fixers/fish_indent.vim @@ -1,12 +1,12 @@ " Author: Chen YuanYuan " Description: Integration of fish_indent with ALE. -call ale#Set('fish_indent_executable', 'fish_indent') -call ale#Set('fish_indent_options', '') +call ale#Set('fish_fishindent_executable', 'fish_indent') +call ale#Set('fish_fishindent_options', '') function! ale#fixers#fish_indent#Fix(buffer) abort - let l:executable = ale#Var(a:buffer, 'fish_indent_executable') - let l:options = ale#Var(a:buffer, 'fish_indent_options') + let l:executable = ale#Var(a:buffer, 'fish_fishindent_executable') + let l:options = ale#Var(a:buffer, 'fish_fishindent_options') let l:filename = ale#Escape(bufname(a:buffer)) return { diff --git a/doc/ale-fish.txt b/doc/ale-fish.txt index 8450b38a..3b9ab44c 100644 --- a/doc/ale-fish.txt +++ b/doc/ale-fish.txt @@ -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 `fish -n ` 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: diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 4f3afd85..ffd53c2a 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -144,6 +144,7 @@ Notes: * `SyntaxErl` * Fish * `fish` (-n flag) + * `fish_indent` * Fortran * `gcc` * `language_server` diff --git a/doc/ale.txt b/doc/ale.txt index eb8f0275..22402afb 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2594,6 +2594,7 @@ documented in additional help files. eruby...................................|ale-eruby-options| ruumba................................|ale-eruby-ruumba| fish....................................|ale-fish-options| + fish_indent...........................|ale-fish-fishindent| 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 49460892..baf26429 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -153,6 +153,7 @@ formatting. * [SyntaxErl](https://github.com/ten0s/syntaxerl) * Fish * fish [-n flag](https://linux.die.net/man/1/fish) + * [fish_indent](https://linux.die.net/man/1/fish_indent) * 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 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..c83300e1 --- /dev/null +++ b/test/fixers/test_fish_indent_fixer_callback.vader @@ -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('')) -- cgit v1.2.3 From 194660660dca4e18f33ac5981ef79856fd062057 Mon Sep 17 00:00:00 2001 From: cyy Date: Mon, 5 Oct 2020 15:30:53 +0700 Subject: update url --- supported-tools.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supported-tools.md b/supported-tools.md index baf26429..f93f2ad1 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -153,7 +153,7 @@ formatting. * [SyntaxErl](https://github.com/ten0s/syntaxerl) * Fish * fish [-n flag](https://linux.die.net/man/1/fish) - * [fish_indent](https://linux.die.net/man/1/fish_indent) + * [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) -- cgit v1.2.3 From a49f664aea742bafae43af50eac568143870a663 Mon Sep 17 00:00:00 2001 From: cyy Date: Wed, 7 Oct 2020 14:04:43 +0700 Subject: chang fishindent to fish_indent --- autoload/ale/fixers/fish_indent.vim | 8 ++++---- doc/ale-fish.txt | 10 +++++----- doc/ale.txt | 2 +- test/fixers/test_fish_indent_fixer_callback.vader | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/autoload/ale/fixers/fish_indent.vim b/autoload/ale/fixers/fish_indent.vim index 98572e47..ebf17c5a 100644 --- a/autoload/ale/fixers/fish_indent.vim +++ b/autoload/ale/fixers/fish_indent.vim @@ -1,12 +1,12 @@ " Author: Chen YuanYuan " Description: Integration of fish_indent with ALE. -call ale#Set('fish_fishindent_executable', 'fish_indent') -call ale#Set('fish_fishindent_options', '') +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_fishindent_executable') - let l:options = ale#Var(a:buffer, 'fish_fishindent_options') + 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 { diff --git a/doc/ale-fish.txt b/doc/ale-fish.txt index 3b9ab44c..7dbbc10c 100644 --- a/doc/ale-fish.txt +++ b/doc/ale-fish.txt @@ -11,17 +11,17 @@ If ALE is not showing any errors but your file does not run as expected, run `fish -n ` from the command line. =============================================================================== -fish_indent *ale-fish-fishindent* +fish_indent *ale-fish-fish_indent* -g:ale_fish_fishindent_executable *g:ale_fish_fishindent_executable* - *b:ale_fish_fishindent_executable* +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_fishindent_options *g:ale_fish_fishindent_options* - *b:ale_fish_fishindent_options* +g:ale_fish_fish_indent_options *g:ale_fish_fish_indent_options* + *b:ale_fish_fish_indent_options* Type: |String| Default: `''` diff --git a/doc/ale.txt b/doc/ale.txt index 22402afb..e7f69011 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2594,7 +2594,7 @@ documented in additional help files. eruby...................................|ale-eruby-options| ruumba................................|ale-eruby-ruumba| fish....................................|ale-fish-options| - fish_indent...........................|ale-fish-fishindent| + fish_indent...........................|ale-fish-fish_indent| fortran.................................|ale-fortran-options| gcc...................................|ale-fortran-gcc| language_server.......................|ale-fortran-language-server| diff --git a/test/fixers/test_fish_indent_fixer_callback.vader b/test/fixers/test_fish_indent_fixer_callback.vader index c83300e1..beb0b42e 100644 --- a/test/fixers/test_fish_indent_fixer_callback.vader +++ b/test/fixers/test_fish_indent_fixer_callback.vader @@ -1,10 +1,10 @@ Before: - Save g:ale_fish_fishindent_executable - Save g:ale_fish_fishindent_options + 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_fishindent_executable = 'xxxinvalid' - let g:ale_fish_fishindent_options = '' + let g:ale_fish_fish_indent_executable = 'xxxinvalid' + let g:ale_fish_fish_indent_options = '' call ale#test#SetDirectory('/testplugin/test/fixers') @@ -26,7 +26,7 @@ Execute(The fish_indent callback should return the correct default values): \ ale#fixers#fish_indent#Fix(bufnr('')) Execute(The fish_indent callback should include custom fish_indent options): - let g:ale_fish_fishindent_options = "-d" + let g:ale_fish_fish_indent_options = "-d" call ale#test#SetFilename('../fish_files/testfile.fish') AssertEqual -- cgit v1.2.3