summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/ormolu.vim12
-rw-r--r--doc/ale-haskell.txt20
-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_ormolu_fixer_callback.vader24
7 files changed, 64 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index d71668f2..377edafd 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -380,6 +380,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['dhall'],
\ 'description': 'Fix Dhall files with dhall-format.',
\ },
+\ 'ormolu': {
+\ 'function': 'ale#fixers#ormolu#Fix',
+\ 'suggested_filetypes': ['haskell'],
+\ 'description': 'A formatter for Haskell source code.',
+\ },
\}
" Reset the function registry to the default entries.
diff --git a/autoload/ale/fixers/ormolu.vim b/autoload/ale/fixers/ormolu.vim
new file mode 100644
index 00000000..69b55c1f
--- /dev/null
+++ b/autoload/ale/fixers/ormolu.vim
@@ -0,0 +1,12 @@
+call ale#Set('haskell_ormolu_executable', 'ormolu')
+call ale#Set('haskell_ormolu_options', '')
+
+function! ale#fixers#ormolu#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_ormolu_executable')
+ let l:options = ale#Var(a:buffer, 'haskell_ormolu_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . (empty(l:options) ? '' : ' ' . l:options),
+ \}
+endfunction
diff --git a/doc/ale-haskell.txt b/doc/ale-haskell.txt
index 5dd3ec15..fde439fe 100644
--- a/doc/ale-haskell.txt
+++ b/doc/ale-haskell.txt
@@ -173,4 +173,24 @@ g:ale_haskell_hie_executable *g:ale_haskell_hie_executable*
===============================================================================
+ormolu *ale-haskell-ormolu*
+
+g:ale_haskell_ormolu_executable *g:ale_haskell_ormolu_executable*
+ *b:ale_haskell_ormolu_executable*
+ Type: |String|
+ Default: `'ormolu'`
+
+ This variable can be changed to use a different executable for ormolu.
+
+
+g:ale_haskell_ormolu_options *g:ale_haskell_ormolu_options*
+ *b:ale_haskell_ormolu_options*
+ Type: String
+ Default: ''
+
+ This variable can be used to pass extra options to the underlying ormolu
+ executable.
+
+
+===============================================================================
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 4f3afd85..57a50dd4 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -195,6 +195,7 @@ Notes:
* `hie`
* `hindent`
* `hlint`
+ * `ormolu`
* `stack-build`!!
* `stack-ghc`
* `stylish-haskell`
diff --git a/doc/ale.txt b/doc/ale.txt
index eb8f0275..01357cd1 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2642,6 +2642,7 @@ documented in additional help files.
stack-ghc.............................|ale-haskell-stack-ghc|
stylish-haskell.......................|ale-haskell-stylish-haskell|
hie...................................|ale-haskell-hie|
+ ormolu................................|ale-haskell-ormolu|
hcl.....................................|ale-hcl-options|
terraform-fmt.........................|ale-hcl-terraform-fmt|
html....................................|ale-html-options|
diff --git a/supported-tools.md b/supported-tools.md
index 49460892..6aa196b2 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -204,6 +204,7 @@ formatting.
* [hie](https://github.com/haskell/haskell-ide-engine)
* [hindent](https://hackage.haskell.org/package/hindent)
* [hlint](https://hackage.haskell.org/package/hlint)
+ * [ormolu](https://github.com/tweag/ormolu)
* [stack-build](https://haskellstack.org/) :floppy_disk:
* [stack-ghc](https://haskellstack.org/)
* [stylish-haskell](https://github.com/jaspervdj/stylish-haskell)
diff --git a/test/fixers/test_ormolu_fixer_callback.vader b/test/fixers/test_ormolu_fixer_callback.vader
new file mode 100644
index 00000000..8df3fca9
--- /dev/null
+++ b/test/fixers/test_ormolu_fixer_callback.vader
@@ -0,0 +1,24 @@
+Before:
+ Save g:ale_haskell_ormolu_executable
+ Save g:ale_haskell_ormolu_options
+
+After:
+ Restore
+
+Execute(The ormolu callback should return the correct default values):
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('ormolu')
+ \ },
+ \ ale#fixers#ormolu#Fix(bufnr(''))
+
+Execute(The ormolu executable and options should be configurable):
+ let g:ale_nix_nixpkgsfmt_executable = '/path/to/ormolu'
+ let g:ale_nix_nixpkgsfmt_options = '-h'
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape('/path/to/ormolu')
+ \ . ' -h',
+ \ },
+ \ ale#fixers#nixpkgsfmt#Fix(bufnr(''))