From 9258c73680c7daa518a9a3bf2c4af6f5eb1b4b5e Mon Sep 17 00:00:00 2001 From: Gordon Fontenot Date: Sun, 4 Mar 2018 10:11:10 -0600 Subject: Fix elm-format fixer name Support for elm-format as a fixer has existed since Sept 2017, but it's not easy to discover because the fixer was named `format`. This breaks the convention of the other fixers that use the full name in the registry. I've gone ahead and fixed this discrepancy, but I left the existing registry entry in place. We should move people towards using `elm-format` as the fixer name, but I'd hate to break existing setups. --- autoload/ale/fix/registry.vim | 11 ++++++----- autoload/ale/fixers/elm_format.vim | 23 +++++++++++++++++++++++ autoload/ale/fixers/format.vim | 23 ----------------------- 3 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 autoload/ale/fixers/elm_format.vim delete mode 100644 autoload/ale/fixers/format.vim (limited to 'autoload') diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 3e407c52..fdd51019 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -23,6 +23,12 @@ let s:default_registry = { \ 'description': 'Apply prettier-standard to a file.', \ 'aliases': ['prettier-standard'], \ }, +\ 'elm-format': { +\ 'function': 'ale#fixers#elm_format#Fix', +\ 'suggested_filetypes': ['elm'], +\ 'description': 'Apply elm-format to a file.', +\ 'aliases': ['format'], +\ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', \ 'suggested_filetypes': ['javascript', 'typescript'], @@ -33,11 +39,6 @@ let s:default_registry = { \ 'suggested_filetypes': ['elixir'], \ 'description': 'Apply mix format 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/elm_format.vim b/autoload/ale/fixers/elm_format.vim new file mode 100644 index 00000000..b2119d2c --- /dev/null +++ b/autoload/ale/fixers/elm_format.vim @@ -0,0 +1,23 @@ +" Author: soywod +" 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#elm_format#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'elm_format', [ + \ 'node_modules/.bin/elm-format', + \]) +endfunction + +function! ale#fixers#elm_format#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'elm_format_options') + + return { + \ 'command': ale#Escape(ale#fixers#elm_format#GetExecutable(a:buffer)) + \ . ' %t' + \ . (empty(l:options) ? '' : ' ' . l:options), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/fixers/format.vim b/autoload/ale/fixers/format.vim deleted file mode 100644 index be130f00..00000000 --- a/autoload/ale/fixers/format.vim +++ /dev/null @@ -1,23 +0,0 @@ -" Author: soywod -" 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 -- cgit v1.2.3