-
Notifications
You must be signed in to change notification settings - Fork 3
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
Code lens for running main
#28
Conversation
src/extension.ts
Outdated
const modulePrefix = relativePath.dir.split(path.delimiter).join('/') | ||
const module = `${modulePrefix}${modulePrefix ? '/' : ''}${relativePath.name}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty sad, we need to convert a relative path to a module path.
It doesn't work for files named "weirdly" like 1-intro.effekt.md
since those aren't valid module identifiers.
A reasonable workaround would be to use something like :import "<path-as-a-string>"
, letting the compiler deal with it. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/effekt-lang/effekt/blob/ad95e3d750b3a67a121ce87a7d3b5135a942ea62/effekt/jvm/src/main/scala/effekt/Repl.scala#L189-L198
We'd duplicate this code, but call it on a path directly instead of calling findSource
https://github.com/effekt-lang/effekt/blob/ad95e3d750b3a67a121ce87a7d3b5135a942ea62/effekt/jvm/src/main/scala/effekt/context/IOModuleDB.scala#L27-L36
// Save the document if it has unsaved changes | ||
const document = await vscode.workspace.openTextDocument(uri); | ||
if (document.isDirty) { | ||
await document.save(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried out a version where this was a pop-up, but it was annoying -- I never want to run the stale version that I can't see...
Addresses the

main
(haha!) part of #12 by adding "Run" options overdef main()
, that opens up a REPL, imports a file, and runs it:How does it work?
def main() =
main
The code still needs heavy refactoring and a bit of testing, this is just a proof of concept born out of frustration.
TODO:
how do other languages manage the terminals? should there always be only at most one for the whole project?~> one per project onlyshould the terminal be even a terminal? wouldn't it be better if it was just an output?~> REPL terminal:import
? (see below)|> Run
button over all of those instead of showing it only over things starting withdef main()
[as outlined in Allow running Effekt programs directly from VS Code #12]