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

Improve project root detection in LSP #1470

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Improve project root detection in LSP #1470

merged 1 commit into from
Oct 16, 2024

Conversation

edemaine
Copy link
Collaborator

This is an attempt at #1094. It seems to work better in development, but there are some aspects specific to dev vs. actual extension that might differ.

  • Populate dist/lib with a tsconfig.json (from new source/tsconfig.json). This helps the LSP figure out that the provided lib files are in their own project root.
  • Detect project roots in more ways, to handle cases with no tsconfig.json:
    • If we're in a node_modules/foo directory, use that. This takes priority over tsconfig.json because findConfigFile searches in all ancestor directories, which could go very far up.
    • Fallback to source project directory only if the opened file is inside that directory. Otherwise, fallback to the directory containing the file (isolation).

I'm still getting the following errors about duplicate definitions. I'm not quite sure why; it seems like TypeScript is loading some libs despite my asking it not to? But at least it's only seven errors, and it seems isolated to the .d.ts file.

image

@edemaine edemaine merged commit ef029a4 into main Oct 16, 2024
4 checks passed
@edemaine edemaine deleted the lsp-roots branch October 16, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants