summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorSimon Bugert <sbugert@users.noreply.github.com>2017-11-05 22:24:41 +0100
committerw0rp <w0rp@users.noreply.github.com>2017-11-05 21:24:41 +0000
commit716b22d524b80941eee6538e988a963f923901f3 (patch)
tree280c4f532ea0b77d8fee1d702fe443fa81cf4f9c /autoload
parent7086586b1776d2b5f3bf87a7f0c25595a5d7e1b0 (diff)
downloadale-716b22d524b80941eee6538e988a963f923901f3.zip
Add shfmt fixer for sh files (#1083)
* Add shfmt fixer for sh files * Add tests for shfmt fixer
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