zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.43k stars 2.89k forks source link

Add "Run" Button for more languages #18629

Open iamkartiknayak opened 2 weeks ago

iamkartiknayak commented 2 weeks ago

Check for existing issues

Describe the feature

Currently only Rust language seems to have the support for Run button to directly execute the file in terminal.

screenshot-2024-10-02-12-56-47

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

No response

AlbertMarashi commented 2 weeks ago

I'm pretty sure other languages also have this feature, and you can manually implement it for other languages using the tasks system, but I am not familiar enough to help you

iamkartiknayak commented 2 weeks ago

But it would be better to have this OOBE

osiewicz commented 2 weeks ago

@AlbertMarashi is right, this is already extendable. It would be great to have it out of the box, but so far nobody from the core team has written tasks for these languages. Contributions are most welcome. :)

notpeter commented 1 week ago

See also:

chitralverma commented 3 days ago

I'm pretty sure other languages also have this feature, and you can manually implement it for other languages using the tasks system, but I am not familiar enough to help you

Hi @AlbertMarashi @osiewicz, Is there some documentation on how to extend this for other languages? would be happy to do this for java, scala etc.

AlbertMarashi commented 3 days ago

maybe @maxdeviant can provide some guidance

notpeter commented 3 days ago

I am not super familiar with the code, but I believe it is just combination of defining tasks and a tree-sitter query to identify areas which can be associated with that task.

Here is where the rust runnable task is defined and given the tag rust-main https://github.com/zed-industries/zed/blob/cdead5760a2c200179e6a51d5a396c33a3e06e3d/crates/languages/src/rust.rs#L495-L512

And here is the tree-sitter runnables.scm which identifies the code which should be tagged rust-main https://github.com/zed-industries/zed/blob/cdead5760a2c200179e6a51d5a396c33a3e06e3d/crates/languages/src/rust/runnables.scm#L29-L40

I recommend you take a look at the existing runnables.scm for the various languages which have them and then search for the tag values (e.g. rust-test, c-main, go-test, etc) to see the associated tasks. You should then also look at the git blame for those lines and you should be able to find the commits where that functionality was added and if there are additional requirements to get everything hooked up properly.