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

MetaLS-like virtual text evaluation instead of comments #4246

Open
leana8959 opened this issue May 20, 2024 · 1 comment
Open

MetaLS-like virtual text evaluation instead of comments #4246

leana8959 opened this issue May 20, 2024 · 1 comment
Labels
type: enhancement New feature or request

Comments

@leana8959
Copy link

Is your enhancement request related to a problem? Please describe.

I find the choice of having evaluation (-- >>>) result as comments suboptimal, since I would like the result to be only shown to the reader of the code and not be a textual part of the document. This is not a blocker, but it can be better.

Describe the solution you'd like

Scala's MetaLS1 supports a special file type: "worksheets". For this kind of files, every expression is evaluated on-the-fly and the value of that line is shown as virtual text on the side.

image

It is worth considering evaluating each (pure) expression and have their value on the right-hand side. It can be an interesting feature, documenting examples for beginners. However, the focus of my suggestion remains on using virtual text over comments.

I have previously opened an issue here mrcjkb/haskell-tools.nvim#258

Describe alternatives you've considered

ghci, but it's nowhere as immersive and intuitive as having inline evaluation on the fly.

Additional context

Maybe long lines will be truncated (at least, I do not know how to avoid it). I might do some research on this when I have free time.

Thank you for the project and for reading my suggestion :)

Footnotes

  1. Meta Language Server

@michaelpj
Copy link
Collaborator

I think the best way to do this would be via proper notebook support. It looks like there may be something like this in the next 3.18 version of the LSP spec. So ideally we would just hook into the notebook support. That would be a big task, though.

However, I guess we possibly could provide an explicitly triggered version of this using inlay hints? Something like:

x :: Int
x = 1 + 2 // eval: <hint>3</hint>

Might be kind of expensive to keep computing, not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants