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.md92
1 files changed, 55 insertions, 37 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index 68a5df27e..647cf6107 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -7,6 +7,16 @@ All capabilities are enabled via `experimental` field of `ClientCapabilities` or
7Requests which we hope to upstream live under `experimental/` namespace. 7Requests which we hope to upstream live under `experimental/` namespace.
8Requests, which are likely to always remain specific to `rust-analyzer` are under `rust-analyzer/` namespace. 8Requests, which are likely to always remain specific to `rust-analyzer` are under `rust-analyzer/` namespace.
9 9
10If you want to be notified about the changes to this document, subscribe to [#4604](https://github.com/rust-analyzer/rust-analyzer/issues/4604).
11
12## `initializationOptions`
13
14As `initializationOptions`, `rust-analyzer` expects `"rust-analyzer"` section of the configuration.
15That is, `rust-analyzer` usually sends `"workspace/configuration"` request with `{ "items": ["rust-analyzer"] }` payload.
16`initializationOptions` should contain the same data that would be in the first item of the result.
17It's OK to not send anything, then all the settings would take their default values.
18However, some settings can not be changed after startup at the moment.
19
10## Snippet `TextEdit` 20## Snippet `TextEdit`
11 21
12**Issue:** https://github.com/microsoft/language-server-protocol/issues/724 22**Issue:** https://github.com/microsoft/language-server-protocol/issues/724
@@ -154,7 +164,7 @@ fn main() {
154} 164}
155``` 165```
156 166
157`experimental/joinLines` yields (curly braces are automagiacally removed) 167`experimental/joinLines` yields (curly braces are automagically removed)
158 168
159```rust 169```rust
160fn main() { 170fn main() {
@@ -301,6 +311,50 @@ Moreover, it would be cool if editors didn't need to implement even basic langua
301 This is how `SelectionRange` request works. 311 This is how `SelectionRange` request works.
302* Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs? 312* Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs?
303 313
314## Runnables
315
316**Issue:** https://github.com/microsoft/language-server-protocol/issues/944
317
318**Server Capability:** `{ "runnables": { "kinds": string[] } }`
319
320This request is send from client to server to get the list of things that can be run (tests, binaries, `cargo check -p`).
321
322**Method:** `experimental/runnables`
323
324**Request:**
325
326```typescript
327interface RunnablesParams {
328 textDocument: TextDocumentIdentifier;
329 /// If null, compute runnables for the whole file.
330 position?: Position;
331}
332```
333
334**Response:** `Runnable[]`
335
336```typescript
337interface Runnable {
338 label: string;
339 /// If this Runnable is associated with a specific function/module, etc, the location of this item
340 location?: LocationLink;
341 /// Running things is necessary technology specific, `kind` needs to be advertised via server capabilities,
342 // the type of `args` is specific to `kind`. The actual running is handled by the client.
343 kind: string;
344 args: any;
345}
346```
347
348rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look like this:
349
350```typescript
351{
352 workspaceRoot?: string;
353 cargoArgs: string[];
354 executableArgs: string[];
355}
356```
357
304## Analyzer Status 358## Analyzer Status
305 359
306**Method:** `rust-analyzer/analyzerStatus` 360**Method:** `rust-analyzer/analyzerStatus`
@@ -389,39 +443,3 @@ interface InlayHint {
389 label: string, 443 label: string,
390} 444}
391``` 445```
392
393## Runnables
394
395**Method:** `rust-analyzer/runnables`
396
397This request is send from client to server to get the list of things that can be run (tests, binaries, `cargo check -p`).
398Note 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.
399Upstream issue: https://github.com/microsoft/language-server-protocol/issues/944
400
401**Request:**
402
403```typescript
404interface RunnablesParams {
405 textDocument: TextDocumentIdentifier;
406 /// If null, compute runnables for the whole file.
407 position?: Position;
408}
409```
410
411**Response:** `Runnable[]`
412
413```typescript
414interface Runnable {
415 /// The range this runnable is applicable for.
416 range: lc.Range;
417 /// The label to show in the UI.
418 label: string;
419 /// The following fields describe a process to spawn.
420 bin: string;
421 args: string[];
422 /// Args for cargo after `--`.
423 extraArgs: string[];
424 env: { [key: string]: string };
425 cwd: string | null;
426}
427```