LuaFormatter
LuaFormatter copied to clipboard
When --[[ style comments are used, the following line gets collapsed into the comment
Using the default config (though I didn't see any config line that would change it), multiline comments using the --[[ --]] syntax get collapsed into the next instruction.
This is in spite of the empty line that was between the comment and the instruction.
diff --git a/CorsixTH/Lua/app.lua b/CorsixTH/Lua/app.lua
index f3d18e8b..a9599952 100644
--- a/CorsixTH/Lua/app.lua
+++ b/CorsixTH/Lua/app.lua
@@ -16,9 +16,7 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE. --]]
-
-local pathsep = package.config:sub(1, 1)
+SOFTWARE. --]] local pathsep = package.config:sub(1, 1)
Same Problem
I found a similar case. Here's a diff showing that the formatter wants to awkwardly join a comment to the end of the previous line:
-- Formatter Configuration
-
require('format').setup {
['*'] = {
{
cmd = {
-- Trim trailing spaces
- [[sed -i 's/\s*$//']],
-
- -- Trim extra trailing newlines (but not the final newline)
- [[sed -i -e ':a' -e '/^\n*$/{$d; N}' -e '/\n$/ba']]
- }
- }
+ [[sed -i 's/\s*$//']], -- Trim extra trailing newlines (but not the final newline)
+ [[sed -i -e ':a' -e '/^\n*$/{$d; N}' -e '/\n$/ba']],
+ },
+ },
Yep, same here
here's a nice easy repo case
--[[ hello ]]
local foo = 1
print(foo)
turns into
--[[ hello ]] local foo = 1
print(foo)
I think the local foo = 1 should remain on its own line.