Merge pull request #1174 from eborden/eborden/add-brittany-for-haskell-formatting

Add brittany for Haskell formatting
This commit is contained in:
w0rp 2017-12-07 19:15:33 +00:00 committed by GitHub
commit 7a71186d62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 2 deletions

View File

@ -105,7 +105,7 @@ formatting.
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
| Haskell | [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt) |
| Haskell | [brittany](https://github.com/lspitzner/brittany), [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt) |
| HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/), [write-good](https://github.com/btford/write-good) |
| Idris | [idris](http://www.idris-lang.org/) |
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) |

View File

@ -139,6 +139,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Fix Haskell files with hfmt.',
\ },
\ 'brittany': {
\ 'function': 'ale#fixers#brittany#Fix',
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Fix Haskell files with brittany.',
\ },
\ 'refmt': {
\ 'function': 'ale#fixers#refmt#Fix',
\ 'suggested_filetypes': ['reason'],

View File

@ -0,0 +1,15 @@
" Author: eborden <evan@evan-borden.com>
" Description: Integration of brittany with ALE.
call ale#Set('haskell_brittany_executable', 'brittany')
function! ale#fixers#brittany#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'haskell_brittany_executable')
return {
\ 'command': ale#Escape(l:executable)
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -2,6 +2,16 @@
ALE Haskell Integration *ale-haskell-options*
===============================================================================
brittany *ale-haskell-brittany*
g:ale_haskell_brittany_executable *g:ale_haskell_brittany_executable*
*b:ale_haskell_brittany_executable*
Type: |String|
Default: `'brittany'`
This variable can be changed to use a different executable for brittany.
===============================================================================
hdevtools *ale-haskell-hdevtools*

View File

@ -80,6 +80,7 @@ CONTENTS *ale-contents*
handlebars............................|ale-handlebars-options|
ember-template-lint.................|ale-handlebars-embertemplatelint|
haskell...............................|ale-haskell-options|
brittany............................|ale-haskell-brittany|
hdevtools...........................|ale-haskell-hdevtools|
hfmt................................|ale-haskell-hfmt|
stack-build.........................|ale-haskell-stack-build|
@ -303,7 +304,7 @@ Notes:
* GraphQL: `eslint`, `gqlint`
* Haml: `haml-lint`
* Handlebars: `ember-template-lint`
* Haskell: `ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`
* Haskell: `brittany`, `ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`
* HTML: `HTMLHint`, `proselint`, `tidy`, `write-good`
* Idris: `idris`
* Java: `checkstyle`, `javac`

View File

@ -0,0 +1,23 @@
Before:
Save g:ale_haskell_brittany_executable
" Use an invalid global executable, so we don't match it.
let g:ale_haskell_brittany_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The brittany 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#brittany#Fix(bufnr(''))