Skip to content

Commit be7a9b6

Browse files
committed
Docs: add ADR010: LSP server
1 parent fc1286d commit be7a9b6

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

docs/architecture/ADR008-Exceptions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ disabling C++ exceptions.
3030

3131
`setjmp`/`longjmp` is foreign to many C++ programmers and is harder to use than
3232
C++ exceptions.
33+
34+
simdjson's On Demand API exposes parse errors in every API call. This means that
35+
error handling code needs to be written all over. simdjson's exception-based On
36+
Demand API would simplify error handling significantly. We haven't determined
37+
yet whether `setjmp`/`longjmp` can be used.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

docs/architecture/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ Nygard][ADR-bible].
199199
* [ADR006: Location tracking](ADR006-Location-tracking.md)
200200
* [ADR008: Exceptions](ADR008-Exceptions.md)
201201
* [ADR009: Website](ADR009-Website.md)
202+
* [ADR010: LSP server](ADR010-LSP-server.md)
202203

203204
### Rejected ADRs
204205

0 commit comments

Comments
 (0)