summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorzandr <7629614+deathlyfrantic@users.noreply.github.com>2020-11-21 10:59:50 -0500
committerGitHub <noreply@github.com>2020-11-21 15:59:50 +0000
commite5d16caebe8a57074ee52d9bf0c0334fba4106a9 (patch)
tree280dc2ea2207e906976c00d53a9f8dc92d5a5f8c /autoload
parent8e28de142affcc60b2b860603d299c44b43a4040 (diff)
downloadale-e5d16caebe8a57074ee52d9bf0c0334fba4106a9.zip
Add luafmt fixer (#3289)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/luafmt.vim13
2 files changed, 18 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index d71668f2..9ea5331b 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -375,6 +375,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['html', 'htmldjango'],
\ 'description': 'Fix HTML files with html-beautify.',
\ },
+\ 'luafmt': {
+\ 'function': 'ale#fixers#luafmt#Fix',
+\ 'suggested_filetypes': ['lua'],
+\ 'description': 'Fix Lua files with luafmt.',
+\ },
\ 'dhall': {
\ 'function': 'ale#fixers#dhall#Fix',
\ 'suggested_filetypes': ['dhall'],
diff --git a/autoload/ale/fixers/luafmt.vim b/autoload/ale/fixers/luafmt.vim
new file mode 100644
index 00000000..6cb9ef4a
--- /dev/null
+++ b/autoload/ale/fixers/luafmt.vim
@@ -0,0 +1,13 @@
+call ale#Set('lua_luafmt_executable', 'luafmt')
+call ale#Set('lua_luafmt_options', '')
+
+function! ale#fixers#luafmt#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'lua_luafmt_executable')
+ let l:options = ale#Var(a:buffer, 'lua_luafmt_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable)
+ \ . (empty(l:options) ? '' : ' ' . l:options)
+ \ . ' --stdin',
+ \}
+endfunction