summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorpatrick brisbin <pbrisbin@gmail.com>2020-08-25 08:57:35 -0400
committerpatrick brisbin <pbrisbin@gmail.com>2020-08-25 09:34:34 -0400
commit447aea4af045b80d63fafe4e65791aa6b7d5b21b (patch)
tree1f909fe3d474da40a41e8e8f50205e2a2b1306aa /autoload
parent3e2abe3f25493af63af91a6013447e378e09f6ec (diff)
downloadale-447aea4af045b80d63fafe4e65791aa6b7d5b21b.zip
Add dhall-format as a Fixer
https://github.com/dhall-lang/dhall-lang
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/dhall.vim23
2 files changed, 28 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