summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2020-08-27 13:39:30 +0100
committerGitHub <noreply@github.com>2020-08-27 13:39:30 +0100
commit5d3d33626cfec083b7e5340df2186b6ed9610916 (patch)
tree8609d1700c445348ee9defdf0684da18ec5c31f1
parent571cff932d7cbfc967559925366100a8f36fb33a (diff)
parent447aea4af045b80d63fafe4e65791aa6b7d5b21b (diff)
downloadale-5d3d33626cfec083b7e5340df2186b6ed9610916.zip
Merge pull request #3310 from pbrisbin/master
Add dhall-format as a Fixer
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/dhall.vim23
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/fixers/test_dhall_fixer_callback.vader11
5 files changed, 43 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 2a38945c..d71668f2 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -375,6 +375,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['html', 'htmldjango'],
\ 'description': 'Fix HTML files with html-beautify.',
\ },
+\ 'dhall': {
+\ 'function': 'ale#fixers#dhall#Fix',
+\ 'suggested_filetypes': ['dhall'],
+\ 'description': 'Fix Dhall files with dhall-format.',
+\ },
\}
" Reset the function registry to the default entries.
diff --git a/autoload/ale/fixers/dhall.vim b/autoload/ale/fixers/dhall.vim
new file mode 100644
index 00000000..18f6006c
--- /dev/null
+++ b/autoload/ale/fixers/dhall.vim
@@ -0,0 +1,23 @@
+" Author: Pat Brisbin <pbrisbin@gmail.com>
+" Description: Integration of dhall-format with ALE.
+
+call ale#Set('dhall_format_executable', 'dhall')
+
+function! ale#fixers#dhall#GetExecutable(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'dhall_format_executable')
+
+ " Dhall is written in Haskell and commonly installed with Stack
+ return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall')
+endfunction
+
+function! ale#fixers#dhall#Fix(buffer) abort
+ let l:executable = ale#fixers#dhall#GetExecutable(a:buffer)
+
+ return {
+ \ 'command': l:executable
+ \ . ' format'
+ \ . ' --inplace'
+ \ . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 677267d8..85ea5d43 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -119,6 +119,8 @@ Notes:
* `dartanalyzer`!!
* `dartfmt`!!
* `language_server`
+* Dhall
+ * `dhall-format`
* Dockerfile
* `dockerfile_lint`
* `hadolint`
diff --git a/supported-tools.md b/supported-tools.md
index 29a06cf5..90fdfca0 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -128,6 +128,8 @@ formatting.
* [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk:
* [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt)
* [language_server](https://github.com/natebosch/dart_language_server)
+* Dhall
+ * [dhall-format](https://github.com/dhall-lang/dhall-lang)
* Dockerfile
* [dockerfile_lint](https://github.com/projectatomic/dockerfile_lint)
* [hadolint](https://github.com/hadolint/hadolint)
diff --git a/test/fixers/test_dhall_fixer_callback.vader b/test/fixers/test_dhall_fixer_callback.vader
new file mode 100644
index 00000000..f27880b7
--- /dev/null
+++ b/test/fixers/test_dhall_fixer_callback.vader
@@ -0,0 +1,11 @@
+Before:
+ call ale#assert#SetUpFixerTest('dhall', 'dhall')
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The default command should be correct):
+ AssertFixer
+ \ { 'read_temporary_file': 1,
+ \ 'command': ale#Escape('dhall') . ' format --inplace %t'
+ \ }