about summary refs log tree commit diff
path: root/editors/code/src/client.ts
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-07-30 19:16:33 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-07-30 19:16:33 +0300
commitbe84f85c1dab75c053e94712bc1028b548206c2f (patch)
tree69ef6e626d8af328ccf5ea3b13d785ccf77a6d05 /editors/code/src/client.ts
parent956e205417eb800b990a44d15cd924b7b3fbc83c (diff)
downloadrust-be84f85c1dab75c053e94712bc1028b548206c2f.tar.gz
rust-be84f85c1dab75c053e94712bc1028b548206c2f.zip
feat: gate custom clint-side commands behind capabilities
Some features of rust-analyzer requires support for custom commands on
the client side. Specifically, hover & code lens need this.

Stock LSP doesn't have a way for the server to know which client-side
commands are available. For that reason, we historically were just
sending the commands, not worrying whether the client supports then or
not.

That's not really great though, so in this PR we add infrastructure for
the client to explicitly opt-into custom commands, via `extensions`
field of the ClientCapabilities.

To preserve backwards compatability, if the client doesn't set the
field, we assume that it does support all custom commands. In the
future, we'll start treating that case as if the client doesn't support
commands.

So, if you maintain a rust-analyzer client and implement
`rust-analyzer/runSingle` and such, please also advertise this via a
capability.
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r--editors/code/src/client.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index b18cf4a20a0..3e9788c98c5 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -178,6 +178,15 @@ class ExperimentalFeatures implements lc.StaticFeature {
         caps.codeActionGroup = true;
         caps.hoverActions = true;
         caps.serverStatusNotification = true;
+        caps.commands = {
+            commands: [
+                "rust-analyzer.runSingle",
+                "rust-analyzer.debugSingle",
+                "rust-analyzer.showReferences",
+                "rust-analyzer.gotoLocation",
+                "editor.action.triggerParameterHints",
+            ]
+        };
         capabilities.experimental = caps;
     }
     initialize(_capabilities: lc.ServerCapabilities<any>, _documentSelector: lc.DocumentSelector | undefined): void {