diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 2b43e40a..430dc7db 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -190,6 +190,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['hack'], \ 'description': 'Fix Hack files with hackfmt.', \ }, +\ 'floskell': { +\ 'function': 'ale#fixers#floskell#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Fix Haskell files with floskell.', +\ }, \ 'hfmt': { \ 'function': 'ale#fixers#hfmt#Fix', \ 'suggested_filetypes': ['haskell'], diff --git a/autoload/ale/fixers/floskell.vim b/autoload/ale/fixers/floskell.vim new file mode 100644 index 00000000..f0015db7 --- /dev/null +++ b/autoload/ale/fixers/floskell.vim @@ -0,0 +1,20 @@ +" Author: robertjlooby +" Description: Integration of floskell with ALE. + +call ale#Set('haskell_floskell_executable', 'floskell') + +function! ale#fixers#floskell#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_floskell_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'floskell') +endfunction + +function! ale#fixers#floskell#Fix(buffer) abort + let l:executable = ale#fixers#floskell#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/doc/ale-haskell.txt b/doc/ale-haskell.txt index 2247eddc..e2073e37 100644 --- a/doc/ale-haskell.txt +++ b/doc/ale-haskell.txt @@ -12,6 +12,16 @@ g:ale_haskell_brittany_executable *g:ale_haskell_brittany_executable* This variable can be changed to use a different executable for brittany. +=============================================================================== +floskell *ale-haskell-floskell* + +g:ale_haskell_floskell_executable *g:ale_haskell_floskell_executable* + *b:ale_haskell_floskell_executable* + Type: |String| + Default: `'floskell'` + + This variable can be changed to use a different executable for floskell. + =============================================================================== ghc *ale-haskell-ghc* diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index b682dc31..89d5ee3b 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -175,6 +175,7 @@ Notes: * Haskell * `brittany` * `cabal-ghc` + * `floskell` * `ghc` * `ghc-mod` * `hdevtools` diff --git a/doc/ale.txt b/doc/ale.txt index 9971d355..dce7a8ae 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -1958,6 +1958,7 @@ documented in additional help files. ember-template-lint...................|ale-handlebars-embertemplatelint| haskell.................................|ale-haskell-options| brittany..............................|ale-haskell-brittany| + floskell..............................|ale-haskell-floskell| ghc...................................|ale-haskell-ghc| ghc-mod...............................|ale-haskell-ghc-mod| cabal-ghc.............................|ale-haskell-cabal-ghc| diff --git a/supported-tools.md b/supported-tools.md index 59f8b082..0b6e04c8 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -184,6 +184,7 @@ formatting. * Haskell * [brittany](https://github.com/lspitzner/brittany) * [cabal-ghc](https://www.haskell.org/cabal/) + * [floskell](https://github.com/ennocramer/floskell) * [ghc](https://www.haskell.org/ghc/) * [ghc-mod](https://github.com/DanielG/ghc-mod) * [hdevtools](https://hackage.haskell.org/package/hdevtools) diff --git a/test/fixers/test_floskell_fixer_callback.vader b/test/fixers/test_floskell_fixer_callback.vader new file mode 100644 index 00000000..66fe9200 --- /dev/null +++ b/test/fixers/test_floskell_fixer_callback.vader @@ -0,0 +1,23 @@ +Before: + Save g:ale_haskell_floskell_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_haskell_floskell_executable = 'xxxinvalid' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The floskell callback should return the correct default values): + call ale#test#SetFilename('../haskell_files/testfile.hs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' %t', + \ }, + \ ale#fixers#floskell#Fix(bufnr(''))