summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Looby <robertjlooby@gmail.com>2019-04-14 11:18:50 -0500
committerRob Looby <robertjlooby@gmail.com>2019-04-14 11:27:48 -0500
commit99361b2ca92bb6b70056ee558088e386745435a6 (patch)
treecf64577f8c7a1176fa71009faab4662676e0923d
parent495bce32e957dcf45d6d6acf183599e18c92b09d (diff)
downloadale-99361b2ca92bb6b70056ee558088e386745435a6.zip
Add floskell for Haskell formatting
-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 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 <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 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(''))