summaryrefslogtreecommitdiff
path: root/autoload/ale
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/ale')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/fourmolu.vim20
2 files changed, 25 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index f7fff6a7..66cdc707 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -561,6 +561,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'A formatter for Haskell source code.',
\ },
+\ 'fourmolu': {
+\ 'function': 'ale#fixers#fourmolu#Fix',
+\ 'suggested_filetypes': ['haskell'],
+\ 'description': 'A formatter for Haskell source code.',
+\ },
\ 'jsonnetfmt': {
\ 'function': 'ale#fixers#jsonnetfmt#Fix',
\ 'suggested_filetypes': ['jsonnet'],
diff --git a/autoload/ale/fixers/fourmolu.vim b/autoload/ale/fixers/fourmolu.vim
new file mode 100644
index 00000000..399ec0f4
--- /dev/null
+++ b/autoload/ale/fixers/fourmolu.vim
@@ -0,0 +1,20 @@
+call ale#Set('haskell_fourmolu_executable', 'fourmolu')
+call ale#Set('haskell_fourmolu_options', '')
+
+function! ale#fixers#fourmolu#GetExecutable(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'haskell_fourmolu_executable')
+
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'fourmolu')
+endfunction
+
+function! ale#fixers#fourmolu#Fix(buffer) abort
+ let l:executable = ale#fixers#fourmolu#GetExecutable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'haskell_fourmolu_options')
+
+ return {
+ \ 'command': l:executable
+ \ . (empty(l:options) ? '' : ' ' . l:options)
+ \ . ' --stdin-input-file '
+ \ . ale#Escape(@%),
+ \}
+endfunction