Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS/TS always use absolute import paths #6115

Closed
1 task done
posthardcode opened this issue Apr 17, 2023 · 6 comments
Closed
1 task done

JS/TS always use absolute import paths #6115

posthardcode opened this issue Apr 17, 2023 · 6 comments
Labels
feature [core label] typescript TypeScript programming language support

Comments

@posthardcode
Copy link

Check for existing issues

  • Completed

Describe the feature

For JavaScript/TypeScript files, Zed currently automatically adds an import when typing a variable name and pressing tab - which is awesome.

It also seems to respect tsconfig and use absolute import paths - but not always. If the module to be imported is at the same level, or a level above, relative paths are used.

Is there a way to force absolute paths to always be used? If not, is this on your roadmap?

Thanks!

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

No response

@hovsater
Copy link
Contributor

I'm not sure this is something Zed can address. Zed delegates most language-specific features to the specific language server. For JavaScript/TypeScript, it's typescript-language-server. Perhaps you could tweak it to your liking by adjusting importModuleSpecifierPreference. 🙂

@hovsater hovsater added awaiting info Issue that needs more information from the user typescript TypeScript programming language support and removed triage labels Apr 20, 2023
@hovsater
Copy link
Contributor

hovsater commented Jun 6, 2023

@posthardcode did you find a solution to your problem?

@reloadedhead
Copy link

@hovsater I did face the same problem, which in other IDEs e.g. VSCode setting the property you mentioned to relative does the job. However, on Zed, having

 "lsp": {
    "typescript-language-server": {
      "initialization_options": {
        "preferences": {
          "importModuleSpecifier": "relative"
        }
      }
    }
  }

on my settings.json apparently has no effect. Am I missing something here?

@hovsater
Copy link
Contributor

@reloadedhead I'm pretty sure the key must be importModuleSpecifierPreference to work. At least judging by the docs.

@reloadedhead
Copy link

@hovsater Indeed, my bad. Caffeine levels were low 😅 can confirm it works like a charm! Extremely happy with Zed :)

@JosephTLyons JosephTLyons removed the awaiting info Issue that needs more information from the user label Sep 29, 2023
@hovsater hovsater closed this as completed Oct 4, 2023
@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@valtism
Copy link

valtism commented Mar 10, 2025

For posterity, to get this working, you need to provide a configuration like this:

{
  "lsp": {
    "vtsls": {
      "settings": {
        "typescript": {
          "preferences": {
            "importModuleSpecifier": "non-relative"
          }
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature [core label] typescript TypeScript programming language support
Projects
None yet
Development

No branches or pull requests

5 participants