zed icon indicating copy to clipboard operation
zed copied to clipboard

Code runner

Open chlorocodes opened this issue 1 year ago • 10 comments

Check for existing issues

  • [X] Completed

Is your feature request related to a problem?

No.

Describe the solution you'd like

I think it would be pretty cool to be able to execute code from within the editor without needing to manually run a node * or python * command from a terminal tab. Basically looking for something similar to VSCode's Code Runner extension.

If applicable, add mockups / screenshots to help present your vision of the feature

VSCode Code Runner

chlorocodes avatar Nov 07 '22 07:11 chlorocodes

Code runner is an essential feature for any text editor that pretends to be a developer's editor. In my Ruby development flow, I constantly hundreds of times a day make changes and run Ruby test scripts from Atom. I still prefer Atom's clean interface and theme having tried VS Code, Sublime, and even Helix.

Atom Script extension is still very convenient because when I run tests and see errors in the full-file-path:line-number format it gives me the ability to navigate exactly to the point just in milliseconds.

Sublime Text has it from the box, at least for C and Ruby - just press Ctrl+B. Atom Script Runner by Ctrl+Shift+B.

Another solution could be to add a sort of shell-commands with the ability to pass the reference to current file in the editor, sort of just ruby %full-path-to-the-current-file-in-editor%

"run-shell-with": [
  {  
     "name": "run Ruby",
     "args": [
        "ruby",
        "%full-path-to-the-current-file-in-editor%", 
        "some other options"
      ]
  },
  {
     "name": "rake test",
     "args": ["rake test"]
  }
]

nvoynov avatar Dec 08 '23 06:12 nvoynov

Hello, it's a very important feature. Of course, you can write your automation on top of AHK-Windows/X11-Linux/whatever, but it's way better to have at least an easy way to land a build-and-run shortcut

olegchir avatar Feb 18 '24 19:02 olegchir

I'm interested in contributing to this issue, but would need some guidance. Could someone please point me in the right direction to start working on this?

Anthony-Eid avatar Feb 27 '24 05:02 Anthony-Eid

Me and @osiewicz are working https://github.com/zed-industries/zed/issues/7108

It is not planned to be as fancy as in the video initially, but soon™ we expect to have a way to have pyhonN some_script.py dynamic tasks in the corresponding modal.

@osiewicz works on that particular bit and things looked good so far, consider pairing with him if you want to work on this particular task.

SomeoneToIgnore avatar Feb 27 '24 07:02 SomeoneToIgnore

I'm interested in pairing with @osiewicz, but I'm still relatively new to the open source community and don't know how I should go about doing that. Should I just send him a message asking to work with him or would it be more appropriate to comment on #7108 about it?

Anthony-Eid avatar Feb 27 '24 19:02 Anthony-Eid

Hey, yeah, tagging is enough; what timezone are you in? I am in GMT+1 and I am (generally speaking) available between 10am and 6pm; if you're in US timezones I can also stay a bit longer, especially on Tuesdays and Thursdays.

osiewicz avatar Feb 27 '24 20:02 osiewicz

I'm in EST so I think you're about 6 hours ahead of me.

Would you be free to pair up this Thursday?

Anthony-Eid avatar Feb 27 '24 20:02 Anthony-Eid

Yep! I've sent you a message on Discord, let's figure out the schedule there.

osiewicz avatar Feb 27 '24 20:02 osiewicz

Hello, is there any updates regarding this issue?

berkaayildiz avatar Apr 14 '24 14:04 berkaayildiz

https://github.com/zed-industries/zed/pull/10548 (will be part of Zed 0.132) had added language tasks to Bash and Python, allowing to run a selection, or the opened file via user's default shell or python3 in it. There are caveats (such as python3-only hardcode), but this is a start for basic cases which hopefully helps many people already.

Zed tasks can be customized and have access to editor selections, so other languages may be supported locally now already. The tasks modal with all tasks applicable for the latest caret position is opened with task::Spawn action or a command panel, also there's a footer button to show the modal and task status: image

What's missing so far:

  • more language support, preferably on the extension level.
  • more logic to better select an appropriate executable for all cases (e.g. python2 or a proper node binary)
  • "run task for current line" + corresponding UI for visibility — @osiewicz works on this and will use the same language task providers

Technically, the issue could be closed and the missing parts considered in follow-ups, but let's keep the issue open at least before the 0.132 is actually released.

SomeoneToIgnore avatar Apr 15 '24 13:04 SomeoneToIgnore