Add floskell for Haskell formatting

This commit is contained in:
Rob Looby 2019-04-14 11:18:50 -05:00
parent 495bce32e9
commit 99361b2ca9
No known key found for this signature in database
GPG Key ID: 0EC7BBF69AF8EA17
7 changed files with 61 additions and 0 deletions

View File

@ -190,6 +190,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['hack'],
\ 'description': 'Fix Hack files with hackfmt.',
\ },
\ 'floskell': {
\ 'function': 'ale#fixers#floskell#Fix',
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Fix Haskell files with floskell.',
\ },
\ 'hfmt': {
\ 'function': 'ale#fixers#hfmt#Fix',
\ 'suggested_filetypes': ['haskell'],

View File

@ -0,0 +1,20 @@
" Author: robertjlooby <robertjlooby@gmail.com>
" Description: Integration of floskell with ALE.
call ale#Set('haskell_floskell_executable', 'floskell')
function! ale#fixers#floskell#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'haskell_floskell_executable')
return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'floskell')
endfunction
function! ale#fixers#floskell#Fix(buffer) abort
let l:executable = ale#fixers#floskell#GetExecutable(a:buffer)
return {
\ 'command': l:executable
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -12,6 +12,16 @@ g:ale_haskell_brittany_executable *g:ale_haskell_brittany_executable*
This variable can be changed to use a different executable for brittany.
===============================================================================
floskell *ale-haskell-floskell*
g:ale_haskell_floskell_executable *g:ale_haskell_floskell_executable*
*b:ale_haskell_floskell_executable*
Type: |String|
Default: `'floskell'`
This variable can be changed to use a different executable for floskell.
===============================================================================
ghc *ale-haskell-ghc*

View File

@ -175,6 +175,7 @@ Notes:
* Haskell
* `brittany`
* `cabal-ghc`
* `floskell`
* `ghc`
* `ghc-mod`
* `hdevtools`

View File

@ -1958,6 +1958,7 @@ documented in additional help files.
ember-template-lint...................|ale-handlebars-embertemplatelint|
haskell.................................|ale-haskell-options|
brittany..............................|ale-haskell-brittany|
floskell..............................|ale-haskell-floskell|
ghc...................................|ale-haskell-ghc|
ghc-mod...............................|ale-haskell-ghc-mod|
cabal-ghc.............................|ale-haskell-cabal-ghc|

View File

@ -184,6 +184,7 @@ formatting.
* Haskell
* [brittany](https://github.com/lspitzner/brittany)
* [cabal-ghc](https://www.haskell.org/cabal/)
* [floskell](https://github.com/ennocramer/floskell)
* [ghc](https://www.haskell.org/ghc/)
* [ghc-mod](https://github.com/DanielG/ghc-mod)
* [hdevtools](https://hackage.haskell.org/package/hdevtools)

View File

@ -0,0 +1,23 @@
Before:
Save g:ale_haskell_floskell_executable
" Use an invalid global executable, so we don't match it.
let g:ale_haskell_floskell_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The floskell callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' %t',
\ },
\ ale#fixers#floskell#Fix(bufnr(''))