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
42.45k stars 2.25k forks source link

Console for print/debugging #12065

Open bicharhamid opened 2 months ago

bicharhamid commented 2 months ago

Check for existing issues

Describe the feature

VS Code has this, XCode has this. It's a super critical part of my workflow and it would be amazing if Zed has it integrated.

The feature? A console that prints out in javascript: "hello world". console.log("Name: " + "John Doe")

There is unfortunately no debugging console and if Zed has it, it would make me delete VSCode

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

Screenshot 2024-05-20 at 4 44 49 PM
bicharhamid commented 2 months ago

Found a way how to do it via Zed Tasks...

Open or Create the tasks.json File:

Define the JavaScript/Python Task:

Here's the task configuration to add:

[
  {
    "label": "Javascript",
    "command": "node $ZED_FILE",
    "env": {},
    "cwd": "$ZED_WORKTREE_ROOT",
    "use_new_terminal": false,
    "allow_concurrent_runs": false,
    "reveal": "always"
  }
]

Note: For Javascript you want to change command to "node $ZED_FILE", For Python you want to change command to "python3 $ZED_FILE", for another language I think you'd have to search for it...

Save the Configuration File: After adding the task configuration, save the tasks.json file.

Accessing and Running the Task: You can now access the tasks modal by using the task::Spawn action or opening it via the command panel.

Select the "Run JavaScript Script" task from the modal to run your JavaScript file.

EXTRA: Adding Keymap Shortcut Sometimes you're like me and you want to make it faster... Heres how:

  1. Command Palette (CMD-SHIFT-P)... open keymap Not default keymap...

  2. Paste this code and edit it to your command:

{
  "context": "Workspace",
  "bindings": {
    "alt-t": ["task::Spawn", { "task_name": "Javascript" }]
  }
}

Change only "alt-t" and task_name "Javascript"

JosephTLyons commented 2 months ago

Hey @bicharhamid, this might of interest to you:

Being able to evaluate JavaScript / Python, inline in the editor