Update lsp to have set root path
This commit is contained in:
@@ -31,6 +31,12 @@
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"command": "nub.setRootPath",
|
||||
"title": "Set root path"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "nub",
|
||||
|
||||
@@ -32,7 +32,19 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
);
|
||||
|
||||
vscode.commands.registerCommand('nub.setRootPath', setRootPath);
|
||||
|
||||
client.start();
|
||||
|
||||
const choice = await vscode.window.showInformationMessage(
|
||||
'Do you want to set the root directory for the project',
|
||||
'Yes',
|
||||
'No'
|
||||
);
|
||||
|
||||
if (choice === 'Yes') {
|
||||
await setRootPath();
|
||||
}
|
||||
}
|
||||
|
||||
export function deactivate(): Thenable<void> | undefined {
|
||||
@@ -41,4 +53,26 @@ export function deactivate(): Thenable<void> | undefined {
|
||||
}
|
||||
|
||||
return client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
async function setRootPath() {
|
||||
if (!client) return;
|
||||
|
||||
const folder = await vscode.window.showOpenDialog({
|
||||
canSelectFolders: true,
|
||||
canSelectFiles: false,
|
||||
canSelectMany: false,
|
||||
openLabel: 'Select root location'
|
||||
});
|
||||
|
||||
if (folder && folder.length > 0) {
|
||||
const newRoot = folder[0].fsPath;
|
||||
|
||||
await client.sendRequest('workspace/executeCommand', {
|
||||
command: 'nub.setRootPath',
|
||||
arguments: [newRoot]
|
||||
});
|
||||
|
||||
vscode.window.showInformationMessage(`Root path set to: ${newRoot}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user