summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorRobert Liebowitz <rliebz@gmail.com>2021-07-03 05:50:48 -0400
committerGitHub <noreply@github.com>2021-07-03 18:50:48 +0900
commit0d90cb64c6d14177f6915649243d272e1308dfaf (patch)
tree1fc1c1d831f966fb1134baad471e518f25b9adc7 /autoload
parentb749ec702af29fb4d8a550c585704b3b351134d9 (diff)
downloadale-0d90cb64c6d14177f6915649243d272e1308dfaf.zip
Add stylua fixer for lua (#3789)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/stylua.vim14
2 files changed, 19 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 1cd5b6ef..5a138484 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -441,6 +441,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['lua'],
\ 'description': 'Fix Lua files with luafmt.',
\ },
+\ 'stylua': {
+\ 'function': 'ale#fixers#stylua#Fix',
+\ 'suggested_filetypes': ['lua'],
+\ 'description': 'Fix Lua files with stylua.',
+\ },
\ 'ormolu': {
\ 'function': 'ale#fixers#ormolu#Fix',
\ 'suggested_filetypes': ['haskell'],
diff --git a/autoload/ale/fixers/stylua.vim b/autoload/ale/fixers/stylua.vim
new file mode 100644
index 00000000..3521c935
--- /dev/null
+++ b/autoload/ale/fixers/stylua.vim
@@ -0,0 +1,14 @@
+" Author: Robert Liebowitz <rliebz@gmail.com>
+" Description: https://github.com/johnnymorganz/stylua
+
+call ale#Set('lua_stylua_executable', 'stylua')
+call ale#Set('lua_stylua_options', '')
+
+function! ale#fixers#stylua#Fix(buffer) abort
+ let l:executable = ale#Var(a:buffer, 'lua_stylua_executable')
+ let l:options = ale#Var(a:buffer, 'lua_stylua_options')
+
+ return {
+ \ 'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' -',
+ \}
+endfunction