aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/lsp-extensions.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev/lsp-extensions.md')
-rw-r--r--docs/dev/lsp-extensions.md95
1 files changed, 89 insertions, 6 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index 55035cfae..209f470eb 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -87,6 +87,40 @@ Invoking code action at this position will yield two code actions for importing
87* Is a fixed two-level structure enough? 87* Is a fixed two-level structure enough?
88* Should we devise a general way to encode custom interaction protocols for GUI refactorings? 88* Should we devise a general way to encode custom interaction protocols for GUI refactorings?
89 89
90## Parent Module
91
92**Issue:** https://github.com/microsoft/language-server-protocol/issues/1002
93
94**Server Capability:** `{ "parentModule": boolean }`
95
96This request is send from client to server to handle "Goto Parent Module" editor action.
97
98**Method:** `experimental/parentModule`
99
100**Request:** `TextDocumentPositionParams`
101
102**Response:** `Location | Location[] | LocationLink[] | null`
103
104
105### Example
106
107```rust
108// src/main.rs
109mod foo;
110// src/foo.rs
111
112/* cursor here*/
113```
114
115`experimental/parentModule` returns a single `Link` to the `mod foo;` declaration.
116
117### Unresolved Question
118
119* An alternative would be to use a more general "gotoSuper" request, which would work for super methods, super classes and super modules.
120 This is the approach IntelliJ Rust is takeing.
121 However, experience shows that super module (which generally has a feeling of navigation between files) should be separate.
122 If you want super module, but the cursor happens to be inside an overriden function, the behavior with single "gotoSuper" request is surprising.
123
90## Join Lines 124## Join Lines
91 125
92**Issue:** https://github.com/microsoft/language-server-protocol/issues/992 126**Issue:** https://github.com/microsoft/language-server-protocol/issues/992
@@ -108,11 +142,7 @@ interface JoinLinesParams {
108} 142}
109``` 143```
110 144
111**Response:** 145**Response:** `TextEdit[]`
112
113```typescript
114TextEdit[]
115```
116 146
117### Example 147### Example
118 148
@@ -138,6 +168,59 @@ fn main() {
138 Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets. 168 Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets.
139 However, it then becomes unclear how it works with multi cursor. 169 However, it then becomes unclear how it works with multi cursor.
140 170
171## On Enter
172
173**Issue:** https://github.com/microsoft/language-server-protocol/issues/1001
174
175**Server Capability:** `{ "onEnter": boolean }`
176
177This request is send from client to server to handle <kbd>Enter</kbd> keypress.
178
179**Method:** `experimental/onEnter`
180
181**Request:**: `TextDocumentPositionParams`
182
183**Response:**
184
185```typescript
186SnippetTextEdit[]
187```
188
189### Example
190
191```rust
192fn main() {
193 // Some /*cursor here*/ docs
194 let x = 92;
195}
196```
197
198`experimental/onEnter` returns the following snippet
199
200```rust
201fn main() {
202 // Some
203 // $0 docs
204 let x = 92;
205}
206```
207
208The primary goal of `onEnter` is to handle automatic indentation when opening a new line.
209This is not yet implemented.
210The secondary goal is to handle fixing up syntax, like continuing doc strings and comments, and escaping `\n` in string literals.
211
212As proper cursor positioning is raison-d'etat for `onEnter`, it uses `SnippetTextEdit`.
213
214### Unresolved Question
215
216* How to deal with synchronicity of the request?
217 One option is to require the client to block until the server returns the response.
218 Another option is to do a OT-style merging of edits from client and server.
219 A third option is to do a record-replay: client applies heuristic on enter immediatelly, then applies all user's keypresses.
220 When the server is ready with the response, the client rollbacks all the changes and applies the recorded actions on top of the correct response.
221* How to deal with multiple carets?
222* Should we extend this to arbitrary typed events and not just `onEnter`?
223
141## Structural Search Replace (SSR) 224## Structural Search Replace (SSR)
142 225
143**Server Capability:** `{ "ssr": boolean }` 226**Server Capability:** `{ "ssr": boolean }`
@@ -265,7 +348,7 @@ Primarily for debugging, but very useful for all people working on rust-analyzer
265```typescript 348```typescript
266interface ExpandMacroParams { 349interface ExpandMacroParams {
267 textDocument: TextDocumentIdentifier, 350 textDocument: TextDocumentIdentifier,
268 position?: Position, 351 position: Position,
269} 352}
270``` 353```
271 354