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
45.61k stars 2.5k forks source link

editor: auto-import style #7626

Open avetisk opened 6 months ago

avetisk commented 6 months ago

Check for existing issues

Describe the feature

There's an option in VS Code called "import module specifier" which allows to choose how the auto-imports are written.

image

This would be great in order to not waste time rewriting all auto-imports to match the desired import style.

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

No response

joaquim-verges commented 6 months ago

Seconding this - this is the main blocker for me to switch fully to Zed

binary-koan commented 5 months ago

Adding this in settings is working for me:

{
  ...
  "lsp": {
    "typescript-language-server": {
      "initialization_options": {
        "preferences": {
          "importModuleSpecifierPreference": "non-relative"
        }
      }
    }
  }
}
antoyne7 commented 1 month ago

This solution is no longer working with vtsls typescript LSP

Adding this in settings is working for me:

{
  ...
  "lsp": {
    "typescript-language-server": {
      "initialization_options": {
        "preferences": {
          "importModuleSpecifierPreference": "non-relative"
        }
      }
    }
  }
}
pcalves commented 1 month ago

FWIW, this works for me after running into the same issue as @antoyne7:

{
  ...
  "language_servers": ["...", "!vtsls", "typescript-language-server"],
  "lsp": {
    "typescript-language-server": {
      "initialization_options": {
        "preferences": {
          "importModuleSpecifierPreference": "non-relative"
        }
      }
    }
  }
}
patrickswijgman commented 1 month ago

I tried all kinds of different ways to configure the vtsls language server but I can't seem to get it working :sob:

  "lsp": {
    "vtsls": {
      "initialization_options": {
        "typescript": {
          "preferences": {
            "importModuleSpecifier": "non-relative",
            "importModuleSpecifierEnding": "js"
          }
        }
      }
    }
  }

Or like so

  "lsp": {
    "vtsls": {
      "initialization_options": {
        "preferences": {
          "typescript.preferences.importModuleSpecifier": "non-relative",
          "typescript.preferences.importModuleSpecifierEnding": "js"
        }
      }
    }
  }

I have looked at the docs of this vtsls language server but I can't seem to get it working. The answer of @pcalves by switching to the typescript-language-server is working but I would like to keep using the standard language server for typescript that Zed offers instead of working around it, if possible

kristiyanraykov commented 3 weeks ago

After trying a good amount of permutations, this ended up doing the work for me with vtsls:

  "lsp": {
    "vtsls": {
      "initialization_options": {
        "typescript": {
          "preferences": {
            "importModuleSpecifier": "relative"
          }
        }
      }
    }
  }