zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.07k stars 3.07k forks source link

Allow overrides for json-language-server settings #20739

Open 4teapo opened 4 hours ago

4teapo commented 4 hours ago

Check for existing issues

Describe the feature

You currently can't customize settings for json-language-server, even though it would be very useful, e.g. to set schemas for certain files without adding a "$schema" to each of them. The YAML module merges user settings with defaults, but the JSON module doesn't.

Environment

Zed: v0.161.2 (Zed) OS: macOS 15.0.1 Memory: 18 GiB Architecture: aarch64

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

No response

notpeter commented 3 hours ago

Do you have any example setting(s) you're looking to use or is it just a custom schema association?

Once implemented I think it would translate to something like this in zed settings.json

  "lsp": {
    "json-language-server": {
      "settings": {
        "json": {
          "schemas": [
            "fileMatch": ["something.json"],
            "schema": "https://json.schemastore.org/babelrc"
          ],
        }
      }
    }
  }

Which would need to merge with the defaults defined here: https://github.com/zed-industries/zed/blob/e25a03cd3c68db346c6d0987981e73efa659386f/crates/languages/src/json.rs#L90-L103

4teapo commented 3 hours ago

Yeah that's exactly what I was thinking as well. And all I was trying to do was custom schema