summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorClément DOUIN <clement.douin@gmail.com>2017-09-09 22:30:20 +0200
committerw0rp <w0rp@users.noreply.github.com>2017-09-09 21:30:20 +0100
commitf3da8f45c15fdd335593be060c0c6aaea751e81d (patch)
tree4c7f3161dfb816ae29e5befc9de5bd869e67aadd /autoload
parentb3a9a0e3e8264cf8ce7c4d3780b06ab62d0db287 (diff)
downloadale-f3da8f45c15fdd335593be060c0c6aaea751e81d.zip
Add elm-format as a new fixer (#916)
* Add elm-format as a new fixer
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/format.vim23
2 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 5b1030d9..e87b02f5 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -27,6 +27,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['javascript', 'typescript'],
\ 'description': 'Apply eslint --fix to a file.',
\ },
+\ 'format': {
+\ 'function': 'ale#fixers#format#Fix',
+\ 'suggested_filetypes': ['elm'],
+\ 'description': 'Apply elm-format to a file.',
+\ },
\ 'isort': {
\ 'function': 'ale#fixers#isort#Fix',
\ 'suggested_filetypes': ['python'],
diff --git a/autoload/ale/fixers/format.vim b/autoload/ale/fixers/format.vim
new file mode 100644
index 00000000..be130f00
--- /dev/null
+++ b/autoload/ale/fixers/format.vim
@@ -0,0 +1,23 @@
+" Author: soywod <clement.douin@gmail.com>
+" Description: Integration of elm-format with ALE.
+
+call ale#Set('elm_format_executable', 'elm-format')
+call ale#Set('elm_format_use_global', 0)
+call ale#Set('elm_format_options', '--yes')
+
+function! ale#fixers#format#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'elm_format', [
+ \ 'node_modules/.bin/elm-format',
+ \])
+endfunction
+
+function! ale#fixers#format#Fix(buffer) abort
+ let l:options = ale#Var(a:buffer, 'elm_format_options')
+
+ return {
+ \ 'command': ale#Escape(ale#fixers#format#GetExecutable(a:buffer))
+ \ . ' %t'
+ \ . (empty(l:options) ? '' : ' ' . l:options),
+ \ 'read_temporary_file': 1,
+ \}
+endfunction