StyLua icon indicating copy to clipboard operation
StyLua copied to clipboard

BUG: Formatter fails on ineger division operator eg.: print(13//3) introduced in lua 5.3

Open SukuWc opened this issue 6 months ago • 3 comments

workaround is to change all integer divisions in my code to math.floor(13/3) but this is much slower in lua

SukuWc avatar Jul 09 '25 09:07 SukuWc

The example print(13//3) works for me. What version of stylua are you using, and do you have anything specific in your stylua.toml?

JohnnyMorganz avatar Aug 10 '25 12:08 JohnnyMorganz

Thanks for taking the time to check my issue!

My stylua.toml:

syntax = "All"
column_width = 80
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "Never"
space_after_function_names = "Never"

[sort_requires]
enabled = false

My .pre-commit-config.yaml:

- repo: https://github.com/JohnnyMorganz/StyLua
  rev: v2.1.0
  hooks:
    - id: stylua # or stylua-system / stylua-github

SukuWc avatar Aug 27 '25 10:08 SukuWc

Aha, your issue is the id: stylua setting in the pre-commit hook.

The default stylua hook will attempt an install via cargo. However, cargo install only builds with default features, which is just Lua 5.1. A previous case of this was in https://github.com/JohnnyMorganz/StyLua/issues/867

I'd recommend changing your hook to use stylua-github, or use stylua-system instead and install stylua independently.

JohnnyMorganz avatar Sep 13 '25 12:09 JohnnyMorganz