You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/generate/README.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,35 @@ Types have been modified to always be union types. A method generator has also b
7
7
## Use
8
8
9
9
From the root of the repo, run
10
+
10
11
```bash
11
12
go run ./cmd/generate_protocol
12
13
```
14
+
13
15
This will generate LSP message types in `internal/protocol`
14
16
15
17
## Key Differences from gopls
16
18
17
19
The main difference from the gopls implementation is in the handling of union types. While gopls simplifies some union types to single types for backward compatibility and easy operability with gopls, this implementation preserves the full union types as specified in the LSP spec.
18
20
21
+
### Custom Field Additions
22
+
23
+
The generator supports adding custom fields to generated types through the `additionalFields` map in `tables.go`. This allows extending LSP types with non-standard fields needed for specific language servers.
24
+
25
+
e.g.
26
+
27
+
```go
28
+
// additionalFields defines extra fields to add to specific types during generation
29
+
// The key is the Go struct name (after applying goName), the value is a slice of field definitions
30
+
varadditionalFields = map[string][]string{
31
+
"BaseSymbolInformation": {
32
+
"Score float64 `json:\"score,omitempty\"` // Added for clangd compatibility",
33
+
},
34
+
}
35
+
```
36
+
37
+
This adds a `Score` field to the `BaseSymbolInformation` type, necessary for `clangd`.
38
+
19
39
## Attribution
20
40
21
41
This folder, and the code generated by the generate command is based on code from the Go tools repository, specifically the gopls language server. It has been modified to prioritize LSP specification compliance over backward compatibility.
@@ -38,7 +58,7 @@ exact version can be tied to a githash. By default, the command will download th
38
58
39
59
The specification has five sections
40
60
41
-
1. Requests, which describe the Request and Response types for request methods (e.g., *textDocument/didChange*),
61
+
1. Requests, which describe the Request and Response types for request methods (e.g., _textDocument/didChange_),
42
62
2. Notifications, which describe the Request types for notification methods,
43
63
3. Structures, which describe named struct-like types,
0 commit comments