# Add autocomplete for initialization_options \(\#43104\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/83449293b67b5b56ba0b02e904649d3eb415ad43)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 83449293b67b5b56ba0b02e904649d3eb415ad43

Requested commit: 83449293b67b5b56ba0b02e904649d3eb415ad43

Commit: 83449293b67b5b56ba0b02e904649d3eb415ad43

Tree: e7ebadb87516fb1f5a0a436dadb03bf2dc9712dd

Author: Nereuxofficial

Committer: GitHub

## Message

```
Add autocomplete for initialization_options (#43104)

Closes #18287

Release Notes:

- Added autocomplete for lsp initialization_options

## Description
This MR adds the following code-changes:
- `initialization_options_schema` to the `LspAdapter` to get JSON
Schema's from the language server
- Adds a post-processing step to inject schema request paths into the
settings schema in `SettingsStore::json_schema`
- Adds an implementation for fetching the schema for rust-analyzer which
fetches it from the binary it is provided with
- Similarly for ruff
<img width="857" height="836" alt="image"
src="https://github.com/user-attachments/assets/3cc10883-364f-4f04-b3b9-3c3881f64252"
/>


## Open Questions(Would be nice to get some advice here)
- Binary Fetching:
- I'm pretty sure the binary fetching is suboptimal. The main problem
here was getting access to the delegate but i figured that out
eventually in a way that i _hope_ should be fine.
- The toolchain and binary options can differ from what the user has
configured potentially leading to mismatches in the autocomplete values
returned(these are probably rarely changed though). I could not really
find a way to fetch these in this context so the provided ones are for
now just `default` values.
- For the trait API it is just provided a binary, since i wanted to use
the potentially cached binary from the CachedLspAdapter. Is that fine
our should the arguments be passed to the LspAdapter such that it can
potentially download the LSP?
- As for those LSPs with JSON schema files in their repositories i can
add the files to zed manually e.g. in
languages/language/initialization_options_schema.json, which could cause
mismatches with the actual binary. Is there a preferred approach for Zed
here also with regards to updating them?
```

## Parents

- [213cb30445208c8c59f02ccd14bd255d6ab2c11e](https://git.cafe/gitcafe/zed/commit/213cb30445208c8c59f02ccd14bd255d6ab2c11e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/83449293b67b5b56ba0b02e904649d3eb415ad43?format=markdown)
