summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/hlint.vim16
-rw-r--r--doc/ale-haskell.txt10
-rw-r--r--doc/ale.txt1
-rw-r--r--test/fixers/test_hlint_fixer_callback.vader25
5 files changed, 57 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 60de4a46..dfcdc98f 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -170,6 +170,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Fix Haskell files with brittany.',
\ },
+\ 'hlint': {
+\ 'function': 'ale#fixers#hlint#Fix',
+\ 'suggested_filetypes': ['haskell'],
+\ 'description': 'Refactor Haskell files with hlint.',
+\ },
\ 'stylish-haskell': {
\ 'function': 'ale#fixers#stylish_haskell#Fix',
\ 'suggested_filetypes': ['haskell'],
diff --git a/autoload/ale/fixers/hlint.vim b/autoload/ale/fixers/hlint.vim
new file mode 100644
index 00000000..94dd736e
--- /dev/null
+++ b/autoload/ale/fixers/hlint.vim
@@ -0,0 +1,16 @@
+" Author: eborden <evan@evan-borden.com>
+" Description: Integration of hlint refactor with ALE.
+"
+call ale#Set('haskell_hlint_executable', 'hlint')
+
+function! ale#fixers#hlint#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_hlint_executable')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . ' --refactor'
+ \ . ' --refactor-options="--inplace"'
+ \ . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/doc/ale-haskell.txt b/doc/ale-haskell.txt
index 9bc9263a..c1f1e889 100644
--- a/doc/ale-haskell.txt
+++ b/doc/ale-haskell.txt
@@ -68,6 +68,16 @@ g:ale_haskell_hfmt_executable *g:ale_haskell_hfmt_executable*
This variable can be changed to use a different executable for hfmt.
===============================================================================
+hlint *ale-haskell-hlint*
+
+g:ale_haskell_hlint_executable *g:ale_haskell_hlint_executable*
+ *b:ale_haskell_hlint_executable*
+ Type: |String|
+ Default: `'hlint'`
+
+ This variable can be changed to use a different executable for hlint.
+
+===============================================================================
stack-build *ale-haskell-stack-build*
g:ale_haskell_stack_build_options *g:ale_haskell_stack_build_options*
diff --git a/doc/ale.txt b/doc/ale.txt
index 2d3efa34..d1e6d0b0 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -110,6 +110,7 @@ CONTENTS *ale-contents*
cabal-ghc...........................|ale-haskell-cabal-ghc|
hdevtools...........................|ale-haskell-hdevtools|
hfmt................................|ale-haskell-hfmt|
+ hlint...............................|ale-haskell-hlint|
stack-build.........................|ale-haskell-stack-build|
stylish-haskell.....................|ale-haskell-stylish-haskell|
hie.................................|ale-haskell-hie|
diff --git a/test/fixers/test_hlint_fixer_callback.vader b/test/fixers/test_hlint_fixer_callback.vader
new file mode 100644
index 00000000..48f26c7c
--- /dev/null
+++ b/test/fixers/test_hlint_fixer_callback.vader
@@ -0,0 +1,25 @@
+Before:
+ Save g:ale_haskell_hlint_executable
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_haskell_hlint_executable = 'xxxinvalid'
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The hlint callback should return the correct default values):
+ call ale#test#SetFilename('../haskell_files/testfile.hs')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' --refactor'
+ \ . ' --refactor-options="--inplace"'
+ \ . ' %t',
+ \ },
+ \ ale#fixers#hlint#Fix(bufnr(''))