mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Implement stop and start server commands
This commit is contained in:
parent
d68616a140
commit
0421756b42
4 changed files with 26 additions and 2 deletions
|
@ -60,6 +60,7 @@
|
||||||
"onCommand:rust-analyzer.analyzerStatus",
|
"onCommand:rust-analyzer.analyzerStatus",
|
||||||
"onCommand:rust-analyzer.memoryUsage",
|
"onCommand:rust-analyzer.memoryUsage",
|
||||||
"onCommand:rust-analyzer.reloadWorkspace",
|
"onCommand:rust-analyzer.reloadWorkspace",
|
||||||
|
"onCommand:rust-analyzer.startServer",
|
||||||
"workspaceContains:*/Cargo.toml",
|
"workspaceContains:*/Cargo.toml",
|
||||||
"workspaceContains:*/rust-project.json"
|
"workspaceContains:*/rust-project.json"
|
||||||
],
|
],
|
||||||
|
@ -191,6 +192,16 @@
|
||||||
"title": "Restart server",
|
"title": "Restart server",
|
||||||
"category": "rust-analyzer"
|
"category": "rust-analyzer"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "rust-analyzer.startServer",
|
||||||
|
"title": "Start server",
|
||||||
|
"category": "rust-analyzer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "rust-analyzer.stopServer",
|
||||||
|
"title": "Stop server",
|
||||||
|
"category": "rust-analyzer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "rust-analyzer.onEnter",
|
"command": "rust-analyzer.onEnter",
|
||||||
"title": "Enhanced enter key",
|
"title": "Enhanced enter key",
|
||||||
|
|
|
@ -76,6 +76,14 @@ export async function createClient(
|
||||||
outputChannel,
|
outputChannel,
|
||||||
middleware: {
|
middleware: {
|
||||||
workspace: {
|
workspace: {
|
||||||
|
// HACK: This is a workaround, when the client has been disposed, VSCode
|
||||||
|
// continues to emit events to the client and the default one for this event
|
||||||
|
// attempt to restart the client for no reason
|
||||||
|
async didChangeWatchedFile(event, next) {
|
||||||
|
if (client.isRunning()) {
|
||||||
|
await next(event);
|
||||||
|
}
|
||||||
|
},
|
||||||
async configuration(
|
async configuration(
|
||||||
params: lc.ConfigurationParams,
|
params: lc.ConfigurationParams,
|
||||||
token: vscode.CancellationToken,
|
token: vscode.CancellationToken,
|
||||||
|
|
|
@ -68,8 +68,6 @@ export class Ctx {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.client) {
|
if (!this.client) {
|
||||||
log.info("Creating language client");
|
|
||||||
|
|
||||||
this._serverPath = await bootstrap(this.extCtx, this.config, this.state).catch(
|
this._serverPath = await bootstrap(this.extCtx, this.config, this.state).catch(
|
||||||
(err) => {
|
(err) => {
|
||||||
let message = "bootstrap error. ";
|
let message = "bootstrap error. ";
|
||||||
|
|
|
@ -126,6 +126,13 @@ async function initCommonContext(ctx: Ctx) {
|
||||||
await ctx.activate();
|
await ctx.activate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ctx.registerCommand("startServer", (_) => async () => {
|
||||||
|
await ctx.activate();
|
||||||
|
});
|
||||||
|
ctx.registerCommand("stopServer", (_) => async () => {
|
||||||
|
// FIXME: We should re-use the client, that is ctx.deactivate() if none of the configs have changed
|
||||||
|
await ctx.disposeClient();
|
||||||
|
});
|
||||||
ctx.registerCommand("analyzerStatus", commands.analyzerStatus);
|
ctx.registerCommand("analyzerStatus", commands.analyzerStatus);
|
||||||
ctx.registerCommand("memoryUsage", commands.memoryUsage);
|
ctx.registerCommand("memoryUsage", commands.memoryUsage);
|
||||||
ctx.registerCommand("shuffleCrateGraph", commands.shuffleCrateGraph);
|
ctx.registerCommand("shuffleCrateGraph", commands.shuffleCrateGraph);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue