diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-25 13:29:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-25 13:29:47 +0100 |
commit | 8686d0b0ac765c2144b22b897de1d8fda68ecc6e (patch) | |
tree | 8cf69f49502a9f2b08d2d2975be79f54f9a04ccb /docs | |
parent | e4f91bfa578e57c1ef4be3343ebb4e8950e5dae6 (diff) | |
parent | 76e170c3d0d0784c0e612c5849798c65a2034f29 (diff) |
Merge #4607
4607: Less rust-analyzer specific onEnter r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/lsp-extensions.md | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 55035cfae..e4b9fb2c2 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md | |||
@@ -138,6 +138,59 @@ fn main() { | |||
138 | Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets. | 138 | 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. | 139 | However, it then becomes unclear how it works with multi cursor. |
140 | 140 | ||
141 | ## On Enter | ||
142 | |||
143 | **Issue:** https://github.com/microsoft/language-server-protocol/issues/1001 | ||
144 | |||
145 | **Server Capability:** `{ "onEnter": boolean }` | ||
146 | |||
147 | This request is send from client to server to handle <kbd>Enter</kbd> keypress. | ||
148 | |||
149 | **Method:** `experimental/onEnter` | ||
150 | |||
151 | **Request:**: `TextDocumentPositionParams` | ||
152 | |||
153 | **Response:** | ||
154 | |||
155 | ```typescript | ||
156 | SnippetTextEdit[] | ||
157 | ``` | ||
158 | |||
159 | ### Example | ||
160 | |||
161 | ```rust | ||
162 | fn main() { | ||
163 | // Some /*cursor here*/ docs | ||
164 | let x = 92; | ||
165 | } | ||
166 | ``` | ||
167 | |||
168 | `experimental/onEnter` returns the following snippet | ||
169 | |||
170 | ```rust | ||
171 | fn main() { | ||
172 | // Some | ||
173 | // $0 docs | ||
174 | let x = 92; | ||
175 | } | ||
176 | ``` | ||
177 | |||
178 | The primary goal of `onEnter` is to handle automatic indentation when opening a new line. | ||
179 | This is not yet implemented. | ||
180 | The secondary goal is to handle fixing up syntax, like continuing doc strings and comments, and escaping `\n` in string literals. | ||
181 | |||
182 | As proper cursor positioning is raison-d'etat for `onEnter`, it uses `SnippetTextEdit`. | ||
183 | |||
184 | ### Unresolved Question | ||
185 | |||
186 | * How to deal with synchronicity of the request? | ||
187 | One option is to require the client to block until the server returns the response. | ||
188 | Another option is to do a OT-style merging of edits from client and server. | ||
189 | A third option is to do a record-replay: client applies heuristic on enter immediatelly, then applies all user's keypresses. | ||
190 | 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. | ||
191 | * How to deal with multiple carets? | ||
192 | * Should we extend this to arbitrary typed events and not just `onEnter`? | ||
193 | |||
141 | ## Structural Search Replace (SSR) | 194 | ## Structural Search Replace (SSR) |
142 | 195 | ||
143 | **Server Capability:** `{ "ssr": boolean }` | 196 | **Server Capability:** `{ "ssr": boolean }` |