Selene, StyLua, and Roblox LSP: What they do, why you should use them

(This post is targeted towards intermediate/advanced developers who use Rojo w/ vscode)

Odds are, if you have Rojo, you have at least 2 of these installed. I like using all of them, and I’ll explain why they’re really cool here, and how they fit into my workflow- because there’s not much information on this tooling out there!

First extension: Selene

Selene by Kampfkarren is an opinionated linter designed for Roblox- but can be used outside of Roblox. It’s a great tool- it helps catch bugs, and keeps your code nice and idiomatic.

One of the biggest parts about development in general is keeping your code clean and readable, which is exactly why selene does. Your code being idiomatic is important, because the majority of people will be able to understand and read it. Selene helps keep your code idiomatic- it catches things like multi-line statements, duplicate keys in tables, empty if statements, unused variables, etc. etc. One really cool thing Selene also does is automatically flag deprecated functions, which means you’ll instantly know when something you use is deprecated.

image

Second extension: StyLua

StyLua by JohnnyMorganz is Lua formatter that goes hand-in-hand with Selene because a lot of the formatting lints are fixed by StyLua. StyLua follows the Roblox style guide- which I recommend you follow. This means your code will always be formatted in a way that’s readable, idiomatic, and follows a style guide that Roblox themselves follows. Since StyLua is an auto-formatter, it can be as simple as pressing Ctrl + S to auto-format your code, which is very helpful.
image


(my personal formatting settings)

Third extension: Roblox LSP

Roblox LSP by Nightrains really is the glue here- it provides highlighting, typechecking, all that for Roblox. It even provides autocomplete inside vscode for things like folders in workspace, which is very nice. I don’t have very much to say about it myself, but it’s impressive. I use it alongside selene, with both Roblox LSP diagnostics, and selene’s lints as well. It’s what works for me.


While a lot of what I’ve said is personalized towards me, I encourage you to find your own balance- don’t shy away from Rojo because it feels awkward for you, because there’s a lot you can personalize. Look at the documentation for selene, Roblox LSP, look at the settings, and try figuring it out! You can go to an extension’s settings through here:
image

14 Likes

Roblox’s linter already does this.

Was planning to switch to Rojo + VSCode, and this is very useful to know, thanks.


Right, but you cannot use a Roblox’s linter in VSCode (and, as far as I know, Selene has more lints available and allows to add custom lints).

1 Like

uhm, it doesn’t?
image
image

image
image

As per the deprecated part, exactly what the post above said. Except it does it prettier
image

Actually you can use Luau linter outside of Roblox. Luau-Lsp makes it easy to use. Or you can download it as an executable.
Luau-Lsp:

Roblox’s linter:

1 Like

Oh, right, totally forgot Luau is open-source. :sweat_smile:

1 Like

I thought you were referring to these:

image