diff options
-rw-r--r-- | crates/rust-analyzer/src/caps.rs | 3 | ||||
-rw-r--r-- | crates/rust-analyzer/src/lsp_ext.rs | 2 | ||||
-rw-r--r-- | docs/dev/lsp-extensions.md | 80 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 2 |
4 files changed, 49 insertions, 38 deletions
diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index 345693524..673795e78 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs | |||
@@ -87,6 +87,9 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti | |||
87 | "ssr": true, | 87 | "ssr": true, |
88 | "onEnter": true, | 88 | "onEnter": true, |
89 | "parentModule": true, | 89 | "parentModule": true, |
90 | "runnables": { | ||
91 | "kinds": [ "cargo" ], | ||
92 | }, | ||
90 | })), | 93 | })), |
91 | } | 94 | } |
92 | } | 95 | } |
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 9381f75d3..5fa1eba1c 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs | |||
@@ -110,7 +110,7 @@ pub enum Runnables {} | |||
110 | impl Request for Runnables { | 110 | impl Request for Runnables { |
111 | type Params = RunnablesParams; | 111 | type Params = RunnablesParams; |
112 | type Result = Vec<Runnable>; | 112 | type Result = Vec<Runnable>; |
113 | const METHOD: &'static str = "rust-analyzer/runnables"; | 113 | const METHOD: &'static str = "experimental/runnables"; |
114 | } | 114 | } |
115 | 115 | ||
116 | #[derive(Serialize, Deserialize, Debug)] | 116 | #[derive(Serialize, Deserialize, Debug)] |
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index b7237ee90..647cf6107 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md | |||
@@ -311,6 +311,50 @@ Moreover, it would be cool if editors didn't need to implement even basic langua | |||
311 | This is how `SelectionRange` request works. | 311 | This is how `SelectionRange` request works. |
312 | * 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? |
313 | 313 | ||
314 | ## Runnables | ||
315 | |||
316 | **Issue:** https://github.com/microsoft/language-server-protocol/issues/944 | ||
317 | |||
318 | **Server Capability:** `{ "runnables": { "kinds": string[] } }` | ||
319 | |||
320 | This 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 | ||
327 | interface 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 | ||
337 | interface 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 | |||
348 | rust-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 | |||
314 | ## Analyzer Status | 358 | ## Analyzer Status |
315 | 359 | ||
316 | **Method:** `rust-analyzer/analyzerStatus` | 360 | **Method:** `rust-analyzer/analyzerStatus` |
@@ -399,39 +443,3 @@ interface InlayHint { | |||
399 | label: string, | 443 | label: string, |
400 | } | 444 | } |
401 | ``` | 445 | ``` |
402 | |||
403 | ## Runnables | ||
404 | |||
405 | **Method:** `rust-analyzer/runnables` | ||
406 | |||
407 | This request is send from client to server to get the list of things that can be run (tests, binaries, `cargo check -p`). | ||
408 | Note 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. | ||
409 | Upstream issue: https://github.com/microsoft/language-server-protocol/issues/944 | ||
410 | |||
411 | **Request:** | ||
412 | |||
413 | ```typescript | ||
414 | interface RunnablesParams { | ||
415 | textDocument: TextDocumentIdentifier; | ||
416 | /// If null, compute runnables for the whole file. | ||
417 | position?: Position; | ||
418 | } | ||
419 | ``` | ||
420 | |||
421 | **Response:** `Runnable[]` | ||
422 | |||
423 | ```typescript | ||
424 | interface Runnable { | ||
425 | /// The range this runnable is applicable for. | ||
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 | kind: "cargo" | "rustc" | "rustup"; | ||
431 | args: string[]; | ||
432 | /// Args for cargo after `--`. | ||
433 | extraArgs: string[]; | ||
434 | env: { [key: string]: string }; | ||
435 | cwd: string | null; | ||
436 | } | ||
437 | ``` | ||
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 73d573678..c51acfccb 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -56,7 +56,7 @@ export interface Runnable { | |||
56 | executableArgs: string[]; | 56 | executableArgs: string[]; |
57 | }; | 57 | }; |
58 | } | 58 | } |
59 | export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("rust-analyzer/runnables"); | 59 | export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>("experimental/runnables"); |
60 | 60 | ||
61 | export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint; | 61 | export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint; |
62 | 62 | ||