UnderMyWheel / vscode-luau

Roblox Luau extension for Visual Studio Code
MIT License
12 stars 2 forks source link

"get service" snippet sets local variable #16

Closed Ozzypig closed 1 year ago

Ozzypig commented 1 year ago

According to the Roblox Lua Style guide:

All services should be referenced using game:GetService at the top of the file.

As such, it makes sense to use this snippet at the beginning of a file, then access the service somewhere else in the file. It is annoying to have to type a variable of the same name, almost eliminating all the time saved by the snippet. This PR modifies the snippet to also set the variable name:

game:GetService("ReplicatedStorage")

...now becomes...

local ReplicatedStorage = game:GetService("ReplicatedStorage")

It may be more appropriate to create an entirely separate snippet for this, but I don't see much point in an inline call to GetService, and it also seems like its against the style guide recommendations.