JohnnyMorganz / StyLua

An opinionated Lua code formatter
Mozilla Public License 2.0
1.6k stars 72 forks source link

Sort variables by length in either ascending or descending order #872

Closed gaymeowing closed 2 weeks ago

gaymeowing commented 4 months ago

Stylua should be able to sort variables in this manner, as what styluas current sort requires/services produces is not that great. It would also be great if this was extended to all variables not just ones for services or requires, as then variables elsewhere would also be nicely sorted

before stylua sort requires:

local playerloaded = require(ServerScriptService.universe.player.playerloaded)
local eventi_util = require(ReplicatedStorage.shared.universe.eventi_util)
local types = require(ReplicatedStorage.shared.universe.eventi_types)
local safeteleport = require(ServerStorage.packages.safeteleport)
local group_info = require(ReplicatedStorage.lists.group_info)
local retryer = require(ReplicatedStorage.packages.retryer)
local grouper = require(ReplicatedStorage.packages.grouper)
local ratelimit = require(ServerStorage.packages.ratelimit)
local pagesutil = require(ServerStorage.packages.pagesutil)
local clock = require(ReplicatedStorage.packages.clock)
local zap = require(ServerScriptService.universe.zap)
local url = require(ServerStorage.packages.url)

after stylua sort requires:

local clock = require(ReplicatedStorage.packages.clock)
local eventi_util = require(ReplicatedStorage.shared.universe.eventi_util)
local group_info = require(ReplicatedStorage.lists.group_info)
local grouper = require(ReplicatedStorage.packages.grouper)
local pagesutil = require(ServerStorage.packages.pagesutil)
local playerloaded = require(ServerScriptService.universe.player.playerloaded)
local ratelimit = require(ServerStorage.packages.ratelimit)
local retryer = require(ReplicatedStorage.packages.retryer)
local safeteleport = require(ServerStorage.packages.safeteleport)
local types = require(ReplicatedStorage.shared.universe.eventi_types)
local url = require(ServerStorage.packages.url)
local zap = require(ServerScriptService.universe.zap)
JohnnyMorganz commented 2 weeks ago

Unfortunately I think it is unlikely that we will support this. StyLua sorts requires lexicographically