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
47.64k stars 2.78k forks source link

Organize Imports Shortcut - CMD + Shift + O #10004

Open AlessandroVol23 opened 6 months ago

AlessandroVol23 commented 6 months ago

Check for existing issues

Describe the feature

In VsCode I use the shortcut (CMD + SHIFT + O) for organizing imports a lot. I can't find the shortcut to set this one custom in the keymap.

I know I can do it with the lightning bolt or CMD + . Is there any way to set a shortcut for organizing imports directly as well?

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

No response

JosephTLyons commented 6 months ago

I think there may be some missing pieces here preventing us from being able to do this through the editor (not entirely sure, to be honest), but a workaround would be to set up a custom formatting task and assign it to a keybinding.

tuzemec commented 5 months ago

Not sure if this counts as a workaround, but I'm executing this on save with the following:

    "TypeScript": {
      "code_actions_on_format": {
        "source.organizeImports": true,
      },
      "format_on_save": {
        "external": {
          "command": "prettier",
          "arguments": ["--stdin-filepath", "{buffer_path}"]
        }
      }
    }

in the language_overrides section of my config file.

I would love to be able to add and "source.removeUnusedImports": true too, but there's some bug that messes up the imports and some get duplicated.