summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/hindent.vim20
-rw-r--r--doc/ale-haskell.txt22
-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_hindent_fixer_callback.vader18
7 files changed, 68 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 3850d782..7a553ccc 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -215,6 +215,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Fix Haskell files with brittany.',
\ },
+\ 'hindent': {
+\ 'function': 'ale#fixers#hindent#Fix',
+\ 'suggested_filetypes': ['haskell'],
+\ 'description': 'Fix Haskell files with hindent.',
+\ },
\ 'hlint': {
\ 'function': 'ale#fixers#hlint#Fix',
\ 'suggested_filetypes': ['haskell'],
diff --git a/autoload/ale/fixers/hindent.vim b/autoload/ale/fixers/hindent.vim
new file mode 100644
index 00000000..b6009a2c
--- /dev/null
+++ b/autoload/ale/fixers/hindent.vim
@@ -0,0 +1,20 @@
+" Author: AlexeiDrake <drake.alexei@gmail.com>
+" Description: Integration of hindent formatting with ALE.
+"
+call ale#Set('haskell_hindent_executable', 'hindent')
+
+function! ale#fixers#hindent#GetExecutable(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_hindent_executable')
+
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hindent')
+endfunction
+
+function! ale#fixers#hindent#Fix(buffer) abort
+ let l:executable = ale#fixers#hindent#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 e2073e37..5dd3ec15 100644
--- a/doc/ale-haskell.txt
+++ b/doc/ale-haskell.txt
@@ -12,6 +12,7 @@ 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*
@@ -22,6 +23,7 @@ g:ale_haskell_floskell_executable *g:ale_haskell_floskell_executable*
This variable can be changed to use a different executable for floskell.
+
===============================================================================
ghc *ale-haskell-ghc*
@@ -32,6 +34,7 @@ g:ale_haskell_ghc_options *g:ale_haskell_ghc_options*
This variable can be changed to modify flags given to ghc.
+
===============================================================================
ghc-mod *ale-haskell-ghc-mod*
@@ -42,6 +45,7 @@ g:ale_haskell_ghc_mod_executable *g:ale_haskell_ghc_mod_executable*
This variable can be changed to use a different executable for ghc-mod.
+
===============================================================================
cabal-ghc *ale-haskell-cabal-ghc*
@@ -53,6 +57,7 @@ g:ale_haskell_cabal_ghc_options *g:ale_haskell_cabal_ghc_options*
This variable can be changed to modify flags given to ghc through cabal
exec.
+
===============================================================================
hdevtools *ale-haskell-hdevtools*
@@ -87,6 +92,18 @@ g:ale_haskell_hfmt_executable *g:ale_haskell_hfmt_executable*
This variable can be changed to use a different executable for hfmt.
+
+===============================================================================
+hindent *ale-haskell-hindent*
+
+g:ale_haskell_hindent_executable *g:ale_haskell_hindent_executable*
+ *b:ale_haskell_hindent_executable*
+ Type: |String|
+ Default: `'hindent'`
+
+ This variable can be changed to use a different executable for hindent.
+
+
===============================================================================
hlint *ale-haskell-hlint*
@@ -106,6 +123,7 @@ g:ale_haskell_hlint_options g:ale_haskell_hlint_options
This variable can be used to pass extra options to the underlying hlint
executable.
+
===============================================================================
stack-build *ale-haskell-stack-build*
@@ -117,6 +135,7 @@ g:ale_haskell_stack_build_options *g:ale_haskell_stack_build_options*
We default to using `'--fast'`. Since Stack generates binaries, your
programs will be slower unless you separately rebuild them outside of ALE.
+
===============================================================================
stack-ghc *ale-haskell-stack-ghc*
@@ -128,6 +147,7 @@ g:ale_haskell_stack_ghc_options *g:ale_haskell_stack_ghc_options*
This variable can be changed to modify flags given to ghc through `stack
ghc`
+
===============================================================================
stylish-haskell *ale-haskell-stylish-haskell*
@@ -139,6 +159,7 @@ g:ale_haskell_stylish_haskell_executable
This variable can be changed to use a different executable for stylish-haskell.
+
===============================================================================
hie *ale-haskell-hie*
@@ -150,5 +171,6 @@ g:ale_haskell_hie_executable *g:ale_haskell_hie_executable*
This variable can be changed to use a different executable for the haskell
ide engine. i.e. `'hie-wrapper'`
+
===============================================================================
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 1a664450..37345f7b 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -183,6 +183,7 @@ Notes:
* `hdevtools`
* `hfmt`
* `hie`
+ * `hindent`
* `hlint`
* `stack-build`!!
* `stack-ghc`
diff --git a/doc/ale.txt b/doc/ale.txt
index 6d8c6a45..beca8546 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2119,6 +2119,7 @@ documented in additional help files.
cabal-ghc.............................|ale-haskell-cabal-ghc|
hdevtools.............................|ale-haskell-hdevtools|
hfmt..................................|ale-haskell-hfmt|
+ hindent...............................|ale-haskell-hindent|
hlint.................................|ale-haskell-hlint|
stack-build...........................|ale-haskell-stack-build|
stack-ghc.............................|ale-haskell-stack-ghc|
diff --git a/supported-tools.md b/supported-tools.md
index 4127edfc..c933f510 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -192,6 +192,7 @@ formatting.
* [hdevtools](https://hackage.haskell.org/package/hdevtools)
* [hfmt](https://github.com/danstiner/hfmt)
* [hie](https://github.com/haskell/haskell-ide-engine)
+ * [hindent](https://hackage.haskell.org/package/hindent)
* [hlint](https://hackage.haskell.org/package/hlint)
* [stack-build](https://haskellstack.org/) :floppy_disk:
* [stack-ghc](https://haskellstack.org/)
diff --git a/test/fixers/test_hindent_fixer_callback.vader b/test/fixers/test_hindent_fixer_callback.vader
new file mode 100644
index 00000000..2e5a8b9f
--- /dev/null
+++ b/test/fixers/test_hindent_fixer_callback.vader
@@ -0,0 +1,18 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The hindent callback should return the correct default values):
+ call ale#test#SetFilename('../haskell_files/testfile.hs')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('hindent')
+ \ . ' %t',
+ \ },
+ \ ale#fixers#hindent#Fix(bufnr(''))