summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/floskell.vim20
-rw-r--r--doc/ale-haskell.txt10
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/fixers/test_floskell_fixer_callback.vader23
7 files changed, 61 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 45da359a..4d28272a 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 <robertjlooby@gmail.com>
+" 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
@@ -13,6 +13,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*
g:ale_haskell_ghc_options *g:ale_haskell_ghc_options*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index acec5926..607c65c2 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 8621426b..755064c1 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2013,6 +2013,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 7768d699..1c02e77c 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(''))