Multi-project ty.toml support: one LanguageClient per project#330
Open
mattparks wants to merge 1 commit intoastral-sh:mainfrom
Open
Multi-project ty.toml support: one LanguageClient per project#330mattparks wants to merge 1 commit intoastral-sh:mainfrom
mattparks wants to merge 1 commit intoastral-sh:mainfrom
Conversation
The ty server creates one project per workspace and resolves extra-paths relative to the workspace root, not the config file directory. This breaks monorepos where each subdirectory has its own ty.toml with different extra-paths. Start a separate LanguageClient per discovered ty.toml, each scoped to its project subtree via documentSelector. A temporary copy of each ty.toml is written with absolute paths so the server resolves them correctly regardless of workspace root. Adds smol-toml to parse and rewrite config files with resolved paths. Ref: astral-sh/ty#693
Member
|
Hmmm I think this is starting a new language server for every |
Author
This makes sense, it looks like there has been an ongoing effort to support mono repos in ty, it looks like the main thread has been under astral-sh/ty#2410 This PR should not merge as is, I still think it was worth sharing as a stop-gap if others need this support now to build tooling on TY while we wait for better support. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds multi-project support for monorepos with multiple
ty.tomlfiles.The ty server creates one project per workspace and resolves
extra-pathsrelative to the workspace root, not the config file directory. Inmonorepos where subdirectories each have their own
ty.tomlwith project-specificextra-paths, this means paths resolve incorrectly and only oneproject can be active at a time.
This PR starts a separate
LanguageClientper discoveredty.toml, each scoped to its project subtree viadocumentSelector. To work around thepath resolution issue, a temporary copy of each
ty.tomlis written with absolute paths and passed asconfigurationFile. AFileSystemWatcherrestarts servers when
ty.tomlfiles are created or deleted.Adds
smol-tomlas a dependency to parse and rewrite config files with resolved paths.Ref: astral-sh/ty#693
Test Plan
Tested in a monorepo with three
ty.tomlfiles at different directory depths, each with differentextra-paths:extra-pathscommand 'ty.printDebugInformation' already existserrors (non-primary clients skipExecuteCommandFeatureregistration)ty.tomlin a fourth directory;FileSystemWatcherdetected it and restarted with the new project includedty.toml; servers restarted without the removed projectty.tomlfiles falls back to a single default serverjust checkpasses (prettier,eslint,tsc)