forked from github-mirrors/ale
Add stylua fixer for lua (#3789)
This commit is contained in:
parent
b749ec702a
commit
0d90cb64c6
|
@ -441,6 +441,11 @@ let s:default_registry = {
|
||||||
\ 'suggested_filetypes': ['lua'],
|
\ 'suggested_filetypes': ['lua'],
|
||||||
\ 'description': 'Fix Lua files with luafmt.',
|
\ 'description': 'Fix Lua files with luafmt.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'stylua': {
|
||||||
|
\ 'function': 'ale#fixers#stylua#Fix',
|
||||||
|
\ 'suggested_filetypes': ['lua'],
|
||||||
|
\ 'description': 'Fix Lua files with stylua.',
|
||||||
|
\ },
|
||||||
\ 'ormolu': {
|
\ 'ormolu': {
|
||||||
\ 'function': 'ale#fixers#ormolu#Fix',
|
\ 'function': 'ale#fixers#ormolu#Fix',
|
||||||
\ 'suggested_filetypes': ['haskell'],
|
\ 'suggested_filetypes': ['haskell'],
|
||||||
|
|
|
@ -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
|
|
@ -46,5 +46,25 @@ g:ale_lua_luafmt_options *g:ale_lua_luafmt_options*
|
||||||
Default: `''`
|
Default: `''`
|
||||||
|
|
||||||
This variable can be set to pass additional options to the luafmt fixer.
|
This variable can be set to pass additional options to the luafmt fixer.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
stylua *ale-lua-stylua*
|
||||||
|
|
||||||
|
g:ale_lua_stylua_executable *g:ale_lua_stylua_executable*
|
||||||
|
*b:ale_lua_stylua_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'stylua'`
|
||||||
|
|
||||||
|
This variable can be set to use a different executable for stylua.
|
||||||
|
|
||||||
|
g:ale_lua_stylua_options *g:ale_lua_stylua_options*
|
||||||
|
*b:ale_lua_stylua_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to the stylua fixer.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
|
|
@ -288,6 +288,7 @@ Notes:
|
||||||
* `luac`
|
* `luac`
|
||||||
* `luacheck`
|
* `luacheck`
|
||||||
* `luafmt`
|
* `luafmt`
|
||||||
|
* `stylua`
|
||||||
* Mail
|
* Mail
|
||||||
* `alex`!!
|
* `alex`!!
|
||||||
* `languagetool`!!
|
* `languagetool`!!
|
||||||
|
|
|
@ -2843,6 +2843,7 @@ documented in additional help files.
|
||||||
luac..................................|ale-lua-luac|
|
luac..................................|ale-lua-luac|
|
||||||
luacheck..............................|ale-lua-luacheck|
|
luacheck..............................|ale-lua-luacheck|
|
||||||
luafmt................................|ale-lua-luafmt|
|
luafmt................................|ale-lua-luafmt|
|
||||||
|
stylua................................|ale-lua-stylua|
|
||||||
markdown................................|ale-markdown-options|
|
markdown................................|ale-markdown-options|
|
||||||
markdownlint..........................|ale-markdown-markdownlint|
|
markdownlint..........................|ale-markdown-markdownlint|
|
||||||
mdl...................................|ale-markdown-mdl|
|
mdl...................................|ale-markdown-mdl|
|
||||||
|
|
|
@ -297,6 +297,7 @@ formatting.
|
||||||
* [luac](https://www.lua.org/manual/5.1/luac.html)
|
* [luac](https://www.lua.org/manual/5.1/luac.html)
|
||||||
* [luacheck](https://github.com/mpeterv/luacheck)
|
* [luacheck](https://github.com/mpeterv/luacheck)
|
||||||
* [luafmt](https://github.com/trixnz/lua-fmt)
|
* [luafmt](https://github.com/trixnz/lua-fmt)
|
||||||
|
* [stylua](https://github.com/johnnymorganz/stylua)
|
||||||
* Mail
|
* Mail
|
||||||
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
* [alex](https://github.com/wooorm/alex) :floppy_disk:
|
||||||
* [languagetool](https://languagetool.org/) :floppy_disk:
|
* [languagetool](https://languagetool.org/) :floppy_disk:
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
Before:
|
||||||
|
call ale#assert#SetUpFixerTest('lua', 'stylua')
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
|
Execute(The default command should be correct):
|
||||||
|
AssertFixer {'command': ale#Escape('stylua') . ' -'}
|
||||||
|
|
||||||
|
Execute(The stylua callback should include custom stylua options):
|
||||||
|
let g:ale_lua_stylua_executable = 'xxxinvalid'
|
||||||
|
let g:ale_lua_stylua_options = '--search-parent-directories'
|
||||||
|
|
||||||
|
AssertFixer
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('xxxinvalid')
|
||||||
|
\ . ' ' . g:ale_lua_stylua_options
|
||||||
|
\ . ' -',
|
||||||
|
\ }
|
Loading…
Reference in New Issue