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

VS Code extension - being able to execute "cells" using Cmd+Enter in .coco file #668

Open
JakartaLaw opened this issue Aug 14, 2022 · 6 comments

Comments

@JakartaLaw
Copy link

It is currently not possible to execute cell from .coco file in VS Code.

A cell is defined by:

# %%
"hello" |> print 
# %%

@evhub evhub added the tooling label Aug 15, 2022
@manisar2
Copy link

manisar2 commented Apr 24, 2023

Also, enabling the feature request above, I think, will automatically add the Shift Enter feature which is used in .py files to send a piece of code to the interactive window and run it there.

If not, just a reminder to add that as well.

@manisar2
Copy link

Found a workaround.
While working on a .coco file, we can still force the editor to treat it as Python file - by hitting Ctrl K M (or by clicking on the language name in the editor towards right at the bottom).

If we do that, we get all these features:

  • automatic cell creation with # %%.
  • send code to the interactive window using Shift Enter. Just remember to use the Coconut kernel in the interactive window so that coconut-inclusive-code is run successfully there..
  • all the usual Python based auto-completion, go-to-definition, find-all-references etc. Remember - all this is otherwise missing while working on a .coco file.

The downside is that syntax will be marked as wrong at the places where coconut specific code is used.

@andrkois
Copy link

i would like to work on this issue

@andrkois
Copy link

andrkois commented May 29, 2024

I wrote a VSCode extension that can run cells on Coconut files. When the user runs the extension, they are presented with the following options:

  • Run everything before the first %##
  • Run everything after the last %##
  • Run the encapsulated block of code
  • Run highlighted code

These options are designed to be self-explanatory. The extension essentially copies the selected block of code to a temp.coco file, which is then compiled and executed on the VS Code terminal.

Detailed Descriptions

  • Run the encapsulated block of code: Runs everything within the first instance of encapsulated code between delimiters (%##).
  • Run highlighted code: Users must ensure the highlighted code does not contain a delimiter, as this will cause a compilation error.

Usage

To run the extension, users should press Ctrl+Shift+P to open the Command Palette and then select the command.

Request for Feedback

I would like some general feedback on my work. Additionally, I have a few specific questions:

  1. Naming and Order: Should I change the names or the order of the choices presented to the user? If so, what changes would you suggest?
  2. Shortcuts: Should I incorporate a shortcut for quick execution of the cells? If yes, what shortcut would you propose?

Future Feature

I am considering adding a feature where, after executing the "Run the encapsulated block of code" option, the user can press a shortcut (e.g., Shift+Enter) to run the next block of code.

  • How does this sound to you?
  • Do you think this would be helpful?

The extention name is CocoCells if you want to try it out!

Thank you in advance for your feedback!

@evhub
Copy link
Owner

evhub commented May 31, 2024

@andrkois Very cool! Is the code open source somewhere?

@andrkois
Copy link

Thank you! I'm glad you find the extension interesting. Currently, the code is not open source, but I can definitely create a GitHub repository for it. This way, the community can contribute to its development and improvement. Would you find that helpful? Alternatively, I can create a pull request (PR) if there are specific changes or integrations you'd like to see. Let me know your thoughts on this approach!

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

4 participants