BUG: Formatter fails on ineger division operator eg.: print(13//3) introduced in lua 5.3
workaround is to change all integer divisions in my code to math.floor(13/3) but this is much slower in lua
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?
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
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.