Repository navigation
Let extensions read file_scan_exclusions, file_scan_inclusions and file_types #66129
AJenbo
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Proposing
Let extensions read three settings for a worktree:
file_scan_exclusions,file_scan_inclusionsandfile_types. An extension that wraps a language server could then forward them, so the server indexes the same files Zed shows the user.This follows up on #66121, which I opened without a discussion first. Sorry about that.
Why this is relevant
A language server that indexes the whole workspace has to decide two things on its own: which files belong to its language, and which paths to skip. Zed has already answered both questions in the user's settings, but an extension can't see the answers.
LanguageSettings,LspSettingsand the context-server settings are all it can read. So the server and the editor disagree:.module,.theme,.incand.installfiles. A user who maps those infile_typesgets PHP highlighting, but the server never indexes them, so every function declared there is reported as undefined.file_scan_inclusionsis how a user makes generated stubs such as_ide_helper.php(Laravel) orwordpress-stubs(WordPress) visible in Zed. Those files exist only to give tooling type information, so the language server is exactly what needs to read them.Today the user has to repeat every one of these under
lsp.<server>.initialization_options, and keep the copies in sync by hand.I maintain PHPantom, a PHP language server that Zed's PHP extension already supports. It accepts these filters from the editor, and the PHP extension forwards them from
initialization_options. The missing piece is reading them from the settings the user has already written.Are there any examples or context?
In VS Code, language servers commonly inherit the editor's file settings, and it's the extension that does the inheriting, not the server:
workspace/configurationrequest and merges everyfiles.associationsglob mapped tophp, and every enabledfiles.excludeglob for that folder, intointelephense.files.*(src/middleware.ts). The server itself only ever asks for theintelephensesection.files.excludeintotailwindCSS.files.exclude(exclusions.ts). Zed's built-in Tailwind adapter doesn't do this either.files.excludeandfiles.associationsfor each workspace folder, forwards them to the server, and sends them again when they change.In Zed, the matching hook is an extension's
language_server_workspace_configuration, but there is nothing for it to merge. The PHP extension's Intelephense adapter returns onlylsp.intelephense.settings, so a.modulefile mapped to PHP infile_typeshas to be listed again underintelephense.files.associations.Related Zed issues show that exclusions not reaching language servers is a known gap. #21018 asks for separate scan, search and tree exclusions because excluding files for language-server reasons affects other features. #63693 describes language-server file watchers loading ignored directories.
Possible approach
Read-only settings access (what extension_api: Expose file scan and file type settings to extensions #66121 did). Two new settings types for the existing
get_settingscall, with no change to the WIT interface:WorktreeSettings::for_worktreereturnsfile_scan_exclusionsandfile_scan_inclusionsas glob strings.FileTypeSettings::for_worktreereturns the effectivefile_typesmap, with Zed's defaults included.The extension decides what to forward.
A smaller version: only return the
file_typesglobs for the extension's own language, perhaps as part ofLanguageSettings. That covers the "file isn't indexed" case with very little new API.Built-in adapters only: Zed's own adapters, such as Tailwind, could forward these settings today without any API change. That helps those servers but leaves every extension-provided server where it is, which is why I'd prefer 1 or 2.
I'm happy to implement whichever one you prefer.
All reactions