summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-10-29 17:37:18 +0000
committerGitHub <noreply@github.com>2019-10-29 17:37:18 +0000
commit2d9380d75c5c27a3241925d24ab3be8977a43207 (patch)
treef045fd328b49f32a588949f2b4f2b2d73662251f
parente259dd525f94576ff40f7ee6a0605229e37506e3 (diff)
parentf89b49a014bb3f5cf0c6820e8b3f4347292b4a06 (diff)
downloadale-2d9380d75c5c27a3241925d24ab3be8977a43207.zip
Merge pull request #2690 from iclanzan/purty
Add purty fixer for PureScript
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/purty.vim22
-rw-r--r--doc/ale-purescript.txt9
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/fixers/test_purty_fixer_callback.vader24
7 files changed, 63 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 4dfe767e..5ec27a10 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -235,6 +235,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'],
diff --git a/autoload/ale/fixers/purty.vim b/autoload/ale/fixers/purty.vim
new file mode 100644
index 00000000..46d2cacd
--- /dev/null
+++ b/autoload/ale/fixers/purty.vim
@@ -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
+
diff --git a/doc/ale-purescript.txt b/doc/ale-purescript.txt
index 33fd2429..e809f2c9 100644
--- a/doc/ale-purescript.txt
+++ b/doc/ale-purescript.txt
@@ -30,4 +30,13 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config
\ }
\}
===============================================================================
+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:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 55be8af5..b7542177 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -349,6 +349,7 @@ Notes:
* `puppet-lint`
* PureScript
* `purescript-language-server`
+ * `purty`
* Python
* `autopep8`
* `bandit`
diff --git a/doc/ale.txt b/doc/ale.txt
index eb3c84d6..f1c2efbb 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2418,6 +2418,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|
diff --git a/supported-tools.md b/supported-tools.md
index de8882f9..324e2000 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -358,6 +358,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:
diff --git a/test/fixers/test_purty_fixer_callback.vader b/test/fixers/test_purty_fixer_callback.vader
new file mode 100644
index 00000000..e83b8c18
--- /dev/null
+++ b/test/fixers/test_purty_fixer_callback.vader
@@ -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(''))