summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorPat Brisbin <pbrisbin@gmail.com>2023-04-22 09:05:50 -0400
committerGitHub <noreply@github.com>2023-04-22 22:05:50 +0900
commit61248e1453dc6373160154e1f6855ffc510a7dfc (patch)
tree4ea12558911cc79317c9adf5961321428bcd8265 /autoload
parentfdadaed2ba93432add241bb25f9935dc2ebb4152 (diff)
downloadale-61248e1453dc6373160154e1f6855ffc510a7dfc.zip
Add fourmolu fixer (#4501)
* Add fourmolu fixer Fourmolu is aversion of Ormolu that supports configuration. This fixer was modeled after the Ormolu one, but using the "stack executable" approach of the Brittany and Stylish Haskell fixers. * Sort supported-tools.md
Diffstat (limited to 'autoload')
-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