summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorsbl <stephen.lumenta@gmail.com>2018-08-26 13:47:56 +0200
committersbl <stephen.lumenta@gmail.com>2018-08-26 13:47:56 +0200
commitaa015ec4db37c4868529f19ced6eeddd70668d26 (patch)
treeb34859b503e953b38fe2a272029296f9e5a04466 /autoload
parent3c85c7ef65242cf80279cf9dcf843523f6d7875b (diff)
downloadale-aa015ec4db37c4868529f19ced6eeddd70668d26.zip
add ocamlformat support
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/ocamlformat.vim18
2 files changed, 23 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index dfcdc98f..ead4e058 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -180,6 +180,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Refactor Haskell files with stylish-haskell.',
\ },
+\ 'ocamlformat': {
+\ 'function': 'ale#fixers#ocamlformat#Fix',
+\ 'suggested_filetypes': ['ocaml'],
+\ 'description': 'Fix OCaml files with ocamlformat.',
+\ },
\ 'refmt': {
\ 'function': 'ale#fixers#refmt#Fix',
\ 'suggested_filetypes': ['reason'],
diff --git a/autoload/ale/fixers/ocamlformat.vim b/autoload/ale/fixers/ocamlformat.vim
new file mode 100644
index 00000000..fac142aa
--- /dev/null
+++ b/autoload/ale/fixers/ocamlformat.vim
@@ -0,0 +1,18 @@
+" Author: Stephen Lumenta <@sbl>
+" Description: Integration of ocamlformat with ALE.
+
+call ale#Set('ocaml_ocamlformat_executable', 'ocamlformat')
+call ale#Set('ocaml_ocamlformat_options', '')
+
+function! ale#fixers#ocamlformat#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'ocaml_ocamlformat_executable')
+ let l:options = ale#Var(a:buffer, 'ocaml_ocamlformat_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . (empty(l:options) ? '' : ' ' . l:options)
+ \ . ' --inplace'
+ \ . ' %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction