From 716b22d524b80941eee6538e988a963f923901f3 Mon Sep 17 00:00:00 2001 From: Simon Bugert Date: Sun, 5 Nov 2017 22:24:41 +0100 Subject: Add shfmt fixer for sh files (#1083) * Add shfmt fixer for sh files * Add tests for shfmt fixer --- autoload/ale/fix/registry.vim | 5 +++++ autoload/ale/fixers/shfmt.vim | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 autoload/ale/fixers/shfmt.vim (limited to 'autoload') diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 37bbee9f..24166da7 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -132,6 +132,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['reason'], \ 'description': 'Fix ReasonML files with refmt.', \ }, +\ 'shfmt': { +\ 'function': 'ale#fixers#shfmt#Fix', +\ 'suggested_filetypes': ['sh'], +\ 'description': 'Fix sh files with shfmt.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/shfmt.vim b/autoload/ale/fixers/shfmt.vim new file mode 100644 index 00000000..882cf3a4 --- /dev/null +++ b/autoload/ale/fixers/shfmt.vim @@ -0,0 +1,17 @@ +scriptencoding utf-8 +" Author: Simon Bugert +" Description: Fix sh files with shfmt. + +call ale#Set('sh_shfmt_executable', 'shfmt') +call ale#Set('sh_shfmt_options', '') + +function! ale#fixers#shfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sh_shfmt_executable') + let l:options = ale#Var(a:buffer, 'sh_shfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \} + +endfunction -- cgit v1.2.3