zed/docs/src
Andrey Kuzmin ac74a72a9e
Improve elm-language-server configuration (#7342)
Hi folks! @absynce and I paired a bit to improve the
`elm-language-server` configuration. We have realised that sometimes
`elm-language-server` settings were being reset to default. We had been
configuring `elm-language-server` like this:

```json
"lsp": {
  "elm-language-server": {
    "initialization_options": {
      "disableElmLSDiagnostics": true,
      "onlyUpdateDiagnosticsOnSave": true,
      "elmReviewDiagnostics": "warning"
    }
  }
}
```

And then we noticed that the following communication happened:

```
// Send:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}
// Receive:
{"jsonrpc":"2.0","id":5,"method":"workspace/configuration","params":{"items":[{"section":"elmLS"}]}}
// Send:
{"jsonrpc":"2.0","id":5,"result":[null],"error":null}
```

In `elm-language-server` the settings from `didChangeConfiguration`
[replace the initial
settings](edd6813388/src/common/providers/diagnostics/diagnosticsProvider.ts (L188)).
Setting the value to `{}` effectively resets the configuration options
to defaults.

In Zed, `initialization_options` and `workspace_configuration` are two
different things, but in `elm-language-server` they are coupled.
Additionally, `elm-language-server` is requesting workspace
configuration for the `elmLS` section that doesn't exist.

This PR: 

1. Fixes settings reset on `didChangeConfiguration` by populating
`workspace_configuration` from `initialization_options`
2. Makes workspace configuration requests work by inserting an extra
copy of the settings under the `elmLS` key in `workspace_configuration`
— this is a bit ugly, but we're not sure how to make both kinds of
configuration messages work in the current setup.

This is how communication looks like after the proposed changes:

```
// Send:
{
  "jsonrpc": "2.0",
  "method": "workspace/didChangeConfiguration",
  "params": {
    "settings": {
      "disableElmLSDiagnostics": true,
      "onlyUpdateDiagnosticsOnSave": true,
      "elmReviewDiagnostics": "warning",
      "elmLS": {
        "disableElmLSDiagnostics": true,
        "onlyUpdateDiagnosticsOnSave": true,
        "elmReviewDiagnostics": "warning"
      }
    }
  }
}
// Receive:
{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "workspace/configuration",
  "params": {
    "items": [
      {
        "section": "elmLS"
      }
    ]
  }
}
// Send:
{
  "jsonrpc": "2.0",
  "id": 4,
  "result": [
    {
      "disableElmLSDiagnostics": true,
      "onlyUpdateDiagnosticsOnSave": true,
      "elmReviewDiagnostics": "warning"
    }
  ],
  "error": null
}
```

Things we have considered:

1. Extracting the `elm-language-server` settings into a separate
section: we haven't found this being widely used in Zed, seems that all
language server configuration should fall under the top level `lsp`
section
2. Changing the way `elm-language-server` configuration works:
`elm-language-server` has got integrations with multiple editors,
changing the configuration behaviour would mean updating all the
existing integrations. Plus we are not exactly sure if it's doing
anything wrong.

Release Notes:

- Improved elm-language-server configuration options

Co-authored-by: Jared M. Smith <absynce@gmail.com>
2024-02-04 01:57:24 +02:00
..
languages Improve elm-language-server configuration (#7342) 2024-02-04 01:57:24 +02:00
CODE_OF_CONDUCT.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00
configuring_zed.md Editor toolbar configuration (#7338) 2024-02-03 22:40:54 +02:00
configuring_zed__configuring_vim.md Remove links to docs.zed.dev (#7187) 2024-01-31 22:26:15 -07:00
configuring_zed__key_bindings.md Update configuring_zed__key_bindings.md (#7310) 2024-02-03 02:15:31 +02:00
developing_zed__adding_languages.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00
developing_zed__building_zed.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00
developing_zed__local_collaboration.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00
feedback.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00
getting_started.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00
SUMMARY.md Restore key bindings docs (#6823) 2024-01-26 19:07:24 -05:00
system_requirements.md Update all links point to community 2024-01-24 15:11:17 -05:00
telemetry.md Adjust heading levels in docs (#7163) 2024-01-31 12:34:31 -05:00