forked from dense-analysis/ale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add luafmt fixer (dense-analysis#3289)
- Loading branch information
1 parent
cf91a6b
commit 5aa56e4
Showing
8 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,6 +266,7 @@ Notes: | |
* Lua | ||
* `luac` | ||
* `luacheck` | ||
* `luafmt` | ||
* `alex`!! | ||
* `languagetool`!! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Before: | ||
Save g:ale_lua_luafmt_executable | ||
Save g:ale_lua_luafmt_options | ||
|
||
" Use an invalid global executable, so we don't match it. | ||
let g:ale_lua_luafmt_executable = 'xxxinvalid' | ||
let g:ale_lua_luafmt_options = '' | ||
|
||
call ale#test#SetDirectory('/testplugin/test/fixers') | ||
|
||
After: | ||
Restore | ||
|
||
call ale#test#RestoreDirectory() | ||
|
||
Execute(The luafmt callback should return the correct default values): | ||
call ale#test#SetFilename('../lua_files/testfile.lua') | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('xxxinvalid') . ' --stdin', | ||
\ }, | ||
\ ale#fixers#luafmt#Fix(bufnr('')) | ||
|
||
Execute(The luafmt callback should include custom luafmt options): | ||
let g:ale_lua_luafmt_options = "--skip-children" | ||
call ale#test#SetFilename('../lua_files/testfile.lua') | ||
|
||
AssertEqual | ||
\ { | ||
\ 'command': ale#Escape('xxxinvalid') | ||
\ . ' ' . g:ale_lua_luafmt_options | ||
\ . ' --stdin', | ||
\ }, | ||
\ ale#fixers#luafmt#Fix(bufnr('')) |
Empty file.