Add purty fixer.

This commit is contained in:
Sorin Iclanzan 2019-08-12 11:49:19 -04:00
parent dd1e1025b8
commit f89b49a014
7 changed files with 63 additions and 0 deletions

View file

@ -225,6 +225,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Refactor Haskell files with stylish-haskell.',
\ },
\ 'purty': {
\ 'function': 'ale#fixers#purty#Fix',
\ 'suggested_filetypes': ['purescript'],
\ 'description': 'Format PureScript files with purty.',
\ },
\ 'ocamlformat': {
\ 'function': 'ale#fixers#ocamlformat#Fix',
\ 'suggested_filetypes': ['ocaml'],

View file

@ -0,0 +1,22 @@
" Author: iclanzan <sorin@iclanzan.com>
" Description: Integration of purty with ALE.
call ale#Set('purescript_purty_executable', 'purty')
function! ale#fixers#purty#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'purescript_purty_executable')
return ale#Escape(l:executable)
endfunction
function! ale#fixers#purty#Fix(buffer) abort
let l:executable = ale#fixers#purty#GetExecutable(a:buffer)
return {
\ 'command': l:executable
\ . ' --write'
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View file

@ -29,5 +29,14 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config
\ 'buildCommand': 'spago build -- --json-errors'
\ }
\}
===============================================================================
purty *ale-purescript-purty*
g:ale_purescript_purty_executable *g:ale_purescript_purty_executable*
*b:ale_purescript_purty_executable*
Type: |String|
Default: `'purty'`
This variable can be changed to use a different executable for purty.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View file

@ -341,6 +341,7 @@ Notes:
* `puppet-lint`
* PureScript
* `purescript-language-server`
* `purty`
* Python
* `autopep8`
* `bandit`

View file

@ -2233,6 +2233,7 @@ documented in additional help files.
puppet-languageserver.................|ale-puppet-languageserver|
purescript..............................|ale-purescript-options|
purescript-language-server............|ale-purescript-language-server|
purty.................................|ale-purescript-purty|
pyrex (cython)..........................|ale-pyrex-options|
cython................................|ale-pyrex-cython|
python..................................|ale-python-options|

View file

@ -350,6 +350,7 @@ formatting.
* [puppet-lint](https://puppet-lint.com)
* PureScript
* [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
* [purty](https://gitlab.com/joneshf/purty)
* Python
* [autopep8](https://github.com/hhatto/autopep8)
* [bandit](https://github.com/PyCQA/bandit) :warning:

View file

@ -0,0 +1,24 @@
Before:
Save g:ale_purescript_purty_executable
" Use an invalid global executable, so we don't match it.
let g:ale_purescript_purty_executable = 'my-special-purty'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The purty callback should return the correct options):
call ale#test#SetFilename('../purescript_files/testfile.purs')
AssertEqual
\ {
\ 'command': ale#Escape('my-special-purty')
\ . ' --write'
\ . ' %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#purty#Fix(bufnr(''))