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

Import from module quick fix #36

Open
DragonDePlatino opened this issue Mar 21, 2021 · 0 comments
Open

Import from module quick fix #36

DragonDePlatino opened this issue Mar 21, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@DragonDePlatino
Copy link

This one's a really huge ask, but would be a huge boost in production speed for Teal. Let's say I've got a file that exports a single thing like this:

local record Pos
	x: integer
	y: integer
end

return Pos

If I start typing Pos in another file, I'd expect to see a class completion at the very top, and hitting enter would automatically complete it and add local Pos = require 'physics.pos' to the list at the top. And the language server would scan all teal files on startup to see what's exported out of each file like this.

Everyone writes their file exports a little differently, but handling the basic case of a single record or named local variable could be a good start. And the quick fix assumes the require would have the same name as the record or variable. If you don't export a named variable and do something more complex like return { A = A, B = B, C = C } we don't bother handling that case for now.

Another point: the style of requires can vary a lot between people so I think a good heuristic is to look at the first line of the file and copy the style of whatever's found there, so you could do local Pos = require("physics.pos") or local Pos = require "physics.pos" or whatever tickles your fancy.

Love the extension, by the way! A language is only as good as it's tooling and VSCode + Teal easily beats out every other embedded scripting language I've seen.

@pdesaulniers pdesaulniers added the enhancement New feature or request label Mar 21, 2021
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

No branches or pull requests

2 participants