|
| 1 | +# ADR010: LSP server |
| 2 | + |
| 3 | +**Status**: Accepted and active. |
| 4 | + |
| 5 | +## Context |
| 6 | + |
| 7 | +The [Language Server Protocol (LSP)][LSP] makes code editor plugins easier to |
| 8 | +write by standardizing several aspects of editor<->language interaction. In an |
| 9 | +LSP world, there are three major components components: |
| 10 | + |
| 11 | +* editor (language-agnostic) |
| 12 | +* editor plugin (LSP client) (editor-specific; language-specific) |
| 13 | +* language server (LSP server) (editor-agnostic; language-specific) |
| 14 | + |
| 15 | +Developers of language tooling are expected to implement the language server. |
| 16 | + |
| 17 | +[LSP]: https://langserver.org/ |
| 18 | + |
| 19 | +## Decision |
| 20 | + |
| 21 | +quick-lint-js develops its own LSP server. It is integrated into the same |
| 22 | +executable as the CLI and is accessible with the `--lsp-server` option. |
| 23 | + |
| 24 | +quick-lint-js develops its own editor plugins. Some of these editor plugins |
| 25 | +utilize the LSP server. |
| 26 | + |
| 27 | +JSON parsing is done with simdjson. JSON serializing is done manually. |
| 28 | + |
| 29 | +## Consequences |
| 30 | + |
| 31 | +LSP has some accidental complexities. For example, locations count the number of |
| 32 | +UTF-16 code units since the beginning of a line. Counting in this way is |
| 33 | +non-trivial for the LSP server and is complicated for some LSP clients (editors) |
| 34 | +too. Non-LSP editor plugins don't necessarily have this complexity; |
| 35 | +quick-lint-js can use the editor's native location scheme without multiple |
| 36 | +layers of translation. |
| 37 | + |
| 38 | +Error handling with simdjson, particularly with its On Demand API, is tedious. |
| 39 | +This is because of [ADR008: Exceptions][ADR008] banning exception in |
| 40 | +quick-lint-js. simdjson's exception-based interface would be much easier to use. |
| 41 | + |
| 42 | +Contrary to what LSP marketing might imply, LSP still requires editor plugins to |
| 43 | +be written for the specific LSP server. Developing and maintaining editor |
| 44 | +plugins for popular editors is still necessary with LSP. |
| 45 | + |
| 46 | +[ADR008]: ./ADR008-Exceptions.md |
0 commit comments