summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/shfmt.vim17
2 files changed, 22 insertions, 0 deletions
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 <simon.bugert@gmail.com>
+" 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