Skip to content
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

Register extra definition files depending on file #29

Open
JohnnyMorganz opened this issue Jun 11, 2022 · 6 comments · May be fixed by #84
Open

Register extra definition files depending on file #29

JohnnyMorganz opened this issue Jun 11, 2022 · 6 comments · May be fixed by #84
Labels
enhancement New feature or request

Comments

@JohnnyMorganz
Copy link
Owner

It would be good to be able to register extra definitions, e.g. testez.d.lua.

We should put this in configuration and make it so it maps globs to extra definitions

@mikejohnstn
Copy link

@JohnnyMorganz I'm not sure how much work this issue will be to implement properly, so in the meantime, would it be possible to just expose this file after the extension is installed?
https://github.com/JohnnyMorganz/luau-lsp/blob/master/scripts/globalTypes.d.lua

If we could simply add to or replace this file (in the VS Code extensions directory) post-installation, that'd be perfect for now.

@JohnnyMorganz
Copy link
Owner Author

@mikejohnstn You should be able to find the file installed at %appdata%\Code\User\globalStorage\johnnymorganz.luau-lsp (or the non-Windows equivalent). Note that it does automatically run an update every Roblox update (which is weekly), so you may have to rewrite it every so often.

Hopefully I'll get something to sort this out soon (and probably another option to disable the auto API update if you don't need it!)

@mikejohnstn
Copy link

Found the file, and works perfectly for now. Thanks!

@mikejohnstn
Copy link

I updated and confirmed the new definition file is working, as well as disabling the Roblox definition file. 👍

A couple issues (and maybe why you haven't closed this yet):

  1. If there's an error while reading the definition file, you only get a very generic message. Is there a way to surface what the problem might be? Otherwise it takes a lot of guessing when you have a typo or other problem in the definitions. My workaround is to manually reload after pretty much every small change to my definition file to make sure it works.

  2. Any way to auto-refresh when the definition file changes, so we don't have to manually reload?

@JohnnyMorganz
Copy link
Owner Author

Definitely want to improve both of these aspects, the issue right now is that definition files are passed and loaded at server startup (using command line flags). We can't display diagnostics until the initialisation handshake is complete, but we load in the file before this. Loading at startup is also why a reboot is required currently.

I plan on looking into deferring the definition files until later, just need to find out a way to cleanly clear the old types and reload the new ones, which is the main hurdle right now. Forcing a reload right now is just me being lazy 😅

  1. If there's an error while reading the definition file, you only get a very generic message. Is there a way to surface what the problem might be? Otherwise it takes a lot of guessing when you have a typo or other problem in the definitions. My workaround is to manually reload after pretty much every small change to my definition file to make sure it works.

What I would recommend for the time being if you are iterating on your definitions file is to run the standalone CLI tool:

luau-lsp analyze --definitions=/path/to/definitions.d.lua test.lua

This should give more helpful error diagnostics if the definitions file fails to load

@mikejohnstn
Copy link

mikejohnstn commented Jun 21, 2022

What I would recommend for the time being if you are iterating on your definitions file is to run the standalone CLI tool

Ah nice, I didn't think of that. Cheers.

@JohnnyMorganz JohnnyMorganz linked a pull request Jul 23, 2022 that will close this issue
@JohnnyMorganz JohnnyMorganz linked a pull request Jul 23, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants