aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/lsp-extensions.md
diff options
context:
space:
mode:
authorMikhail Rakhmanov <[email protected]>2020-06-13 07:42:15 +0100
committerMikhail Rakhmanov <[email protected]>2020-06-13 07:42:15 +0100
commit16bbf4ab7f132e6e5e5318dccdef9a5d71afdd7f (patch)
tree4b79fa8c046be56b02427ba843e70cdf3ac05767 /docs/dev/lsp-extensions.md
parenteeb8b9e236796da8734ba81a49164864497f7226 (diff)
parentb56ad148db0c69eb279c225f45d324b4e80e7367 (diff)
Merge branch 'master' into keyword_completion
# Conflicts: # docs/user/generated_features.adoc
Diffstat (limited to 'docs/dev/lsp-extensions.md')
-rw-r--r--docs/dev/lsp-extensions.md122
1 files changed, 96 insertions, 26 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index c57a93f12..a0847dad3 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -97,6 +97,30 @@ Invoking code action at this position will yield two code actions for importing
97* Is a fixed two-level structure enough? 97* Is a fixed two-level structure enough?
98* Should we devise a general way to encode custom interaction protocols for GUI refactorings? 98* Should we devise a general way to encode custom interaction protocols for GUI refactorings?
99 99
100## Lazy assists with `ResolveCodeAction`
101
102**Issue:** https://github.com/microsoft/language-server-protocol/issues/787
103
104**Client Capability** `{ "resolveCodeAction": boolean }`
105
106If this capability is set, the assists will be computed lazily. Thus `CodeAction` returned from the server will only contain `id` but not `edit` or `command` fields. The only exclusion from the rule is the diagnostic edits.
107
108After the client got the id, it should then call `experimental/resolveCodeAction` command on the server and provide the following payload:
109
110```typescript
111interface ResolveCodeActionParams {
112 id: string;
113 codeActionParams: lc.CodeActionParams;
114}
115```
116
117As a result of the command call the client will get the respective workspace edit (`lc.WorkspaceEdit`).
118
119### Unresolved Questions
120
121* Apply smarter filtering for ids?
122* Upon `resolveCodeAction` command only call the assits which should be resolved and not all of them?
123
100## Parent Module 124## Parent Module
101 125
102**Issue:** https://github.com/microsoft/language-server-protocol/issues/1002 126**Issue:** https://github.com/microsoft/language-server-protocol/issues/1002
@@ -311,6 +335,50 @@ Moreover, it would be cool if editors didn't need to implement even basic langua
311 This is how `SelectionRange` request works. 335 This is how `SelectionRange` request works.
312* Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs? 336* Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs?
313 337
338## Runnables
339
340**Issue:** https://github.com/microsoft/language-server-protocol/issues/944
341
342**Server Capability:** `{ "runnables": { "kinds": string[] } }`
343
344This request is send from client to server to get the list of things that can be run (tests, binaries, `cargo check -p`).
345
346**Method:** `experimental/runnables`
347
348**Request:**
349
350```typescript
351interface RunnablesParams {
352 textDocument: TextDocumentIdentifier;
353 /// If null, compute runnables for the whole file.
354 position?: Position;
355}
356```
357
358**Response:** `Runnable[]`
359
360```typescript
361interface Runnable {
362 label: string;
363 /// If this Runnable is associated with a specific function/module, etc, the location of this item
364 location?: LocationLink;
365 /// Running things is necessary technology specific, `kind` needs to be advertised via server capabilities,
366 // the type of `args` is specific to `kind`. The actual running is handled by the client.
367 kind: string;
368 args: any;
369}
370```
371
372rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look like this:
373
374```typescript
375{
376 workspaceRoot?: string;
377 cargoArgs: string[];
378 executableArgs: string[];
379}
380```
381
314## Analyzer Status 382## Analyzer Status
315 383
316**Method:** `rust-analyzer/analyzerStatus` 384**Method:** `rust-analyzer/analyzerStatus`
@@ -400,38 +468,40 @@ interface InlayHint {
400} 468}
401``` 469```
402 470
403## Runnables 471## Hover Actions
404
405**Method:** `rust-analyzer/runnables`
406 472
407This request is send from client to server to get the list of things that can be run (tests, binaries, `cargo check -p`). 473**Client Capability:** `{ "hoverActions": boolean }`
408Note that we plan to move this request to `experimental/runnables`, as it is not really Rust-specific, but the current API is not necessary the right one.
409Upstream issue: https://github.com/microsoft/language-server-protocol/issues/944
410 474
411**Request:** 475If this capability is set, `Hover` request returned from the server might contain an additional field, `actions`:
412 476
413```typescript 477```typescript
414interface RunnablesParams { 478interface Hover {
415 textDocument: TextDocumentIdentifier; 479 ...
416 /// If null, compute runnables for the whole file. 480 actions?: CommandLinkGroup[];
417 position?: Position;
418} 481}
419```
420 482
421**Response:** `Runnable[]` 483interface CommandLink extends Command {
484 /**
485 * A tooltip for the command, when represented in the UI.
486 */
487 tooltip?: string;
488}
422 489
423```typescript 490interface CommandLinkGroup {
424interface Runnable { 491 title?: string;
425 /// The range this runnable is applicable for. 492 commands: CommandLink[];
426 range: lc.Range;
427 /// The label to show in the UI.
428 label: string;
429 /// The following fields describe a process to spawn.
430 bin: string;
431 args: string[];
432 /// Args for cargo after `--`.
433 extraArgs: string[];
434 env: { [key: string]: string };
435 cwd: string | null;
436} 493}
437``` 494```
495
496Such actions on the client side are appended to a hover bottom as command links:
497```
498 +-----------------------------+
499 | Hover content |
500 | |
501 +-----------------------------+
502 | _Action1_ | _Action2_ | <- first group, no TITLE
503 +-----------------------------+
504 | TITLE _Action1_ | _Action2_ | <- second group
505 +-----------------------------+
506 ...
507``` \ No newline at end of file