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

REPL? #129

Open
michaelmesser opened this issue Dec 29, 2021 · 7 comments
Open

REPL? #129

michaelmesser opened this issue Dec 29, 2021 · 7 comments

Comments

@michaelmesser
Copy link
Contributor

michaelmesser commented Dec 29, 2021

Microsoft considers REPL out of scope for LSP, but that doesn't mean we can't implement it anyways. This leaves us a few options:

Questions:

  • Are there any better ways to tackles the issue than what I mentioned above?
  • Would REPL state be cleared when changing focus between files?
  • Would each file have its own REPL state?
  • Would every file change reset the REPL?
@Russoul
Copy link
Member

Russoul commented Dec 29, 2021

We can stick to native Idris2’ REPL behavior for your last three bullet points, at least provisionally.

That is:

  • Keep state when changing between files. (There is no corresponding operation in the native REPL, but I don’t see why we’d want to wipe out the state on a file swap)
  • Have one global REPL state.
  • Every file change resets REPL.

@michaelmesser
Copy link
Contributor Author

I'm not sure that it is possible to easily implement a :load that keeps the old state. I'm also not sure that every file change resetting the REPL is optimal (especially if/when the Idris API supports check as you type) because some users may want the REPL to stay on the last version with no errors.

@Russoul
Copy link
Member

Russoul commented Dec 29, 2021

Wow, I actually completely missed that we have :load in idris2' REPL. Is it of any use for LSP users? Loading a file is as simple as opening it in the editor. Why would anyone want to do that via a command?

Holding off on resetting the REPL state until we've made sure the file type checked successfully sounds great. Keep the old state if the recent type-checking attempt resulted in errors.

@michaelmesser
Copy link
Contributor Author

michaelmesser commented Dec 29, 2021

Another problem is that LSP doesn't have share Idris's concept of a single file loaded at a time. More than one file can be open at a time. In fact, we don't even know which document is currently focused, but we could have editor plugins tell us when focus changes or include the focused document when sending REPL commands. If there is a global REPL, instead of one REPL per file, how would the user specify which file would be loaded when the command is run?

@Russoul
Copy link
Member

Russoul commented Dec 29, 2021

ATM, I personally think that if someone is interested in developing the idea into a working prototype, it's best to just stick to what's within easy reach based on what's currently offered by the Idris2 api. We've seen that api needs some reconstruction to accommodate all our wishes :) But that's a very long-term venture.

@michaelmesser
Copy link
Contributor Author

The issue for Haskell Language Server is haskell/haskell-language-server#477. If they are able to find a solution, we may be able to do something similar.

@herkhinah
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants