-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to not use require / consider the whole project #887
Comments
Very interesting to hear that Farming Simulator uses Luau! Switching away from considering require and instead using the whole source tree might be a bit challenging. The way the Luau analysis library is built revolves around tying files together using require syntax, so I would need to see how we could get around that. How do files reference other files then - I'm guessing functions and variables just end up getting loaded into the global namespace, and can reference each other depending on their ordering in the XML file? You might find quicker success here by using requires normally and then creating a quick post processing tool to remove the require lines |
Oh that sounds like an interesting trick, it would involve adding a require and return at the end of the file but could work. And each mod has their own environment so to speak but through But a suggestion would be adding a comment/option with an luau lsp option, e.g. And yes the order is determined by the order in the xml, or if the |
A few days ago I figured out that Farming Simulator 25 is using luau and not lua, thought it seems it's nowhere mentioned.
I just saw
_G._VERSION = "Luau"
and some testing confirmed it.So I tried setting up an project to use the features of Luau in vscode/vscodium but since Giants (FS25 Developer) modified the implementation they don't have a require function.
They provide two ways to include a file in a mod, either through their modDesc.xml file or with the global function
source(filePath)
.Though
source()
can not be seen as a require replacement, since it doesn't return anything from the file but loads it.I setup a little minimal project to showcase this but also for testing the difinition of the FS25 api.
https://github.com/SyBozzDEV/FS25_luau_test-setup
The enhancement / request I would like to suggest is an option to disable require and allow the lsp to consider all luau / lua files, maybe by setting the files to consider e.g.
src/
. I think that way would allow a more general usage since adding the specific LS25 functionality seems a bit much.Though maybe there are already ways to achieve this with some settings or tricks I didn't find.
I did find the trick where I could setup a type definition for the project but that would mean to always write double the amount and have to deal with the
BuiltinGlobalWrite
message.The text was updated successfully, but these errors were encountered: