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
50.22k stars 3.09k forks source link

Allow executing slash commands in editor #20095

Open mlavrinenko opened 2 weeks ago

mlavrinenko commented 2 weeks ago

Check for existing issues

Describe the feature

It would be awesome to allow executing of slash commands not only in assistant panel, but in editor too.

Suggested implementation:

  1. Ctrl+Enter opens inline assistant prompt input (no changes needed)
  2. User writes anything, including one or many slash commands (change needed: it's impossible to write a slash command here for now)
  3. Alt+Enter to insert all the prompt text without assistant executing it (change needed)

Sometimes 2 & 3 can be helpful even by themselves.

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

Potential usage examples for default commands:

  1. /terminal to copy output error in a code comment (like after solving a bug with a crutch and noticing why it was made)
  2. /symbols to make table of contents in markdown file (documentation)
  3. /fetch a file from github to an empty file
  4. /file or /tab to fill new file from some another (template) file
  5. /now to add some visible timestamp in a code comment

Potential usage examples for made up but possible commands that can be helpful in both assistant and editor:

  1. /uuid to insert a random uuid
  2. /steampipe "select first_name, last_name from users;" --export=json to get JSON data using steampipe
dlants commented 1 day ago

I think some way to add the current buffer to the context while doing an inline prompt is sorely needed. Is it added by default? (would be nice to document that if so) This would be a really nice way to do it.