Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command to stop the clangd server and provides a auto-start configuration. #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@
},
"description": "Arguments for clangd server."
},
"clangd.autoStart": {
"type": "boolean",
"default": true,
"description": "Start clangd language server automatically when opening a file or project.",
"scope": "resource"
},
"clangd.trace": {
"type": "string",
"description": "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format."
Expand Down Expand Up @@ -179,6 +185,11 @@
"category": "clangd",
"title": "Restart language server"
},
{
"command": "clangd.stop",
"category": "clangd",
"title": "Stop language server"
},
{
"command": "clangd.typeHierarchy",
"category": "clangd",
Expand Down
11 changes: 9 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ export async function activate(context: vscode.ExtensionContext) {
await clangdContext.activate(context.globalStoragePath, outputChannel,
context.workspaceState);
}));
context.subscriptions.push(
vscode.commands.registerCommand('clangd.stop', async () => {
await clangdContext.dispose();
}));

await clangdContext.activate(context.globalStoragePath, outputChannel,
context.workspaceState);
const autoStart = vscode.workspace.getConfiguration('clangd').get('autoStart');
if (autoStart) {
await clangdContext.activate(context.globalStoragePath, outputChannel,
context.workspaceState);
}

const shouldCheck = vscode.workspace.getConfiguration('clangd').get(
'detectExtensionConflicts');
Expand Down