Add purty fixer.
This commit is contained in:
parent
dd1e1025b8
commit
f89b49a014
7 changed files with 63 additions and 0 deletions
|
@ -225,6 +225,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['haskell'],
|
\ 'suggested_filetypes': ['haskell'],
|
||||||
\ 'description': 'Refactor Haskell files with stylish-haskell.',
|
\ 'description': 'Refactor Haskell files with stylish-haskell.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'purty': {
|
||||||
|
\ 'function': 'ale#fixers#purty#Fix',
|
||||||
|
\ 'suggested_filetypes': ['purescript'],
|
||||||
|
\ 'description': 'Format PureScript files with purty.',
|
||||||
|
\ },
|
||||||
\ 'ocamlformat': {
|
\ 'ocamlformat': {
|
||||||
\ 'function': 'ale#fixers#ocamlformat#Fix',
|
\ 'function': 'ale#fixers#ocamlformat#Fix',
|
||||||
\ 'suggested_filetypes': ['ocaml'],
|
\ 'suggested_filetypes': ['ocaml'],
|
||||||
|
|
22
autoload/ale/fixers/purty.vim
Normal file
22
autoload/ale/fixers/purty.vim
Normal 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
|
||||||
|
|
|
@ -29,5 +29,14 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config
|
||||||
\ 'buildCommand': 'spago build -- --json-errors'
|
\ '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:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -341,6 +341,7 @@ Notes:
|
||||||
* `puppet-lint`
|
* `puppet-lint`
|
||||||
* PureScript
|
* PureScript
|
||||||
* `purescript-language-server`
|
* `purescript-language-server`
|
||||||
|
* `purty`
|
||||||
* Python
|
* Python
|
||||||
* `autopep8`
|
* `autopep8`
|
||||||
* `bandit`
|
* `bandit`
|
||||||
|
|
|
@ -2233,6 +2233,7 @@ documented in additional help files.
|
||||||
puppet-languageserver.................|ale-puppet-languageserver|
|
puppet-languageserver.................|ale-puppet-languageserver|
|
||||||
purescript..............................|ale-purescript-options|
|
purescript..............................|ale-purescript-options|
|
||||||
purescript-language-server............|ale-purescript-language-server|
|
purescript-language-server............|ale-purescript-language-server|
|
||||||
|
purty.................................|ale-purescript-purty|
|
||||||
pyrex (cython)..........................|ale-pyrex-options|
|
pyrex (cython)..........................|ale-pyrex-options|
|
||||||
cython................................|ale-pyrex-cython|
|
cython................................|ale-pyrex-cython|
|
||||||
python..................................|ale-python-options|
|
python..................................|ale-python-options|
|
||||||
|
|
|
@ -350,6 +350,7 @@ formatting.
|
||||||
* [puppet-lint](https://puppet-lint.com)
|
* [puppet-lint](https://puppet-lint.com)
|
||||||
* PureScript
|
* PureScript
|
||||||
* [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
|
* [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
|
||||||
|
* [purty](https://gitlab.com/joneshf/purty)
|
||||||
* Python
|
* Python
|
||||||
* [autopep8](https://github.com/hhatto/autopep8)
|
* [autopep8](https://github.com/hhatto/autopep8)
|
||||||
* [bandit](https://github.com/PyCQA/bandit) :warning:
|
* [bandit](https://github.com/PyCQA/bandit) :warning:
|
||||||
|
|
24
test/fixers/test_purty_fixer_callback.vader
Normal file
24
test/fixers/test_purty_fixer_callback.vader
Normal 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(''))
|
Reference in a new issue