commit
96428425fe
7 changed files with 64 additions and 0 deletions
|
@ -385,6 +385,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['dhall'],
|
\ 'suggested_filetypes': ['dhall'],
|
||||||
\ 'description': 'Fix Dhall files with dhall-format.',
|
\ '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.
|
" Reset the function registry to the default entries.
|
||||||
|
|
12
autoload/ale/fixers/ormolu.vim
Normal file
12
autoload/ale/fixers/ormolu.vim
Normal file
|
@ -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
|
|
@ -172,5 +172,25 @@ g:ale_haskell_hie_executable *g:ale_haskell_hie_executable*
|
||||||
ide engine. i.e. `'hie-wrapper'`
|
ide engine. i.e. `'hie-wrapper'`
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
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:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -196,6 +196,7 @@ Notes:
|
||||||
* `hie`
|
* `hie`
|
||||||
* `hindent`
|
* `hindent`
|
||||||
* `hlint`
|
* `hlint`
|
||||||
|
* `ormolu`
|
||||||
* `stack-build`!!
|
* `stack-build`!!
|
||||||
* `stack-ghc`
|
* `stack-ghc`
|
||||||
* `stylish-haskell`
|
* `stylish-haskell`
|
||||||
|
|
|
@ -2693,6 +2693,7 @@ documented in additional help files.
|
||||||
stack-ghc.............................|ale-haskell-stack-ghc|
|
stack-ghc.............................|ale-haskell-stack-ghc|
|
||||||
stylish-haskell.......................|ale-haskell-stylish-haskell|
|
stylish-haskell.......................|ale-haskell-stylish-haskell|
|
||||||
hie...................................|ale-haskell-hie|
|
hie...................................|ale-haskell-hie|
|
||||||
|
ormolu................................|ale-haskell-ormolu|
|
||||||
hcl.....................................|ale-hcl-options|
|
hcl.....................................|ale-hcl-options|
|
||||||
terraform-fmt.........................|ale-hcl-terraform-fmt|
|
terraform-fmt.........................|ale-hcl-terraform-fmt|
|
||||||
html....................................|ale-html-options|
|
html....................................|ale-html-options|
|
||||||
|
|
|
@ -205,6 +205,7 @@ formatting.
|
||||||
* [hie](https://github.com/haskell/haskell-ide-engine)
|
* [hie](https://github.com/haskell/haskell-ide-engine)
|
||||||
* [hindent](https://hackage.haskell.org/package/hindent)
|
* [hindent](https://hackage.haskell.org/package/hindent)
|
||||||
* [hlint](https://hackage.haskell.org/package/hlint)
|
* [hlint](https://hackage.haskell.org/package/hlint)
|
||||||
|
* [ormolu](https://github.com/tweag/ormolu)
|
||||||
* [stack-build](https://haskellstack.org/) :floppy_disk:
|
* [stack-build](https://haskellstack.org/) :floppy_disk:
|
||||||
* [stack-ghc](https://haskellstack.org/)
|
* [stack-ghc](https://haskellstack.org/)
|
||||||
* [stylish-haskell](https://github.com/jaspervdj/stylish-haskell)
|
* [stylish-haskell](https://github.com/jaspervdj/stylish-haskell)
|
||||||
|
|
24
test/fixers/test_ormolu_fixer_callback.vader
Normal file
24
test/fixers/test_ormolu_fixer_callback.vader
Normal file
|
@ -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(''))
|
Reference in a new issue