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 9ea5331b..64e65214 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -385,6 +385,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 469f5fc9..60b53c03 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -196,6 +196,7 @@ Notes:
* `hie`
* `hindent`
* `hlint`
+ * `ormolu`
* `stack-build`!!
* `stack-ghc`
* `stylish-haskell`
diff --git a/doc/ale.txt b/doc/ale.txt
index e00d5f15..c5de4333 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2693,6 +2693,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 0aa25761..ec49ad19 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -205,6 +205,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(''))