-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qbs implements the LSP server partially starts from Qbs v2.2.0, but a more usefull LSP support starts from Qbs v2.3.0. This suport belongs to Qbs API level greater than 4, so, right now, the VSCode extension will use the LSP features for Qbs language only for that mention Qbs versions, and more newest.
- Loading branch information
1 parent
0171027
commit f4c9d19
Showing
6 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import { | ||
LanguageClient, | ||
LanguageClientOptions, | ||
MessageTransports, | ||
} from 'vscode-languageclient/node'; | ||
|
||
import { createServerPipeTransport } from 'vscode-languageserver-protocol/node'; | ||
|
||
export class QbsLanguageClient implements vscode.Disposable { | ||
private languageClient?: LanguageClient; | ||
|
||
public constructor(pipeName: string) { | ||
const serverOptions = this.createMessageTransports(pipeName); | ||
const clientOptions: LanguageClientOptions = { | ||
documentSelector: [{ language: 'qbs' }], | ||
}; | ||
console.info('Starting Qbs language client on pipe: ' + pipeName); | ||
this.languageClient = new LanguageClient('Qbs', (async () => serverOptions), clientOptions, true); | ||
this.languageClient | ||
.start() | ||
.then(async () => { | ||
console.info('Qbs language client started on pipe: ' + pipeName); | ||
}) | ||
.catch((reason) => { | ||
void vscode.window.showErrorMessage('Cannot start Qbs language server'); | ||
console.error('Unable to start Qbs language client on pipe: ' + pipeName + ', ' + reason); | ||
}); | ||
|
||
} | ||
|
||
public dispose(): void { this.languageClient?.dispose(); } | ||
|
||
private async createMessageTransports(pipeName: string): Promise<MessageTransports> { | ||
return new Promise<MessageTransports>(async (resolve) => { | ||
const transport = createServerPipeTransport(pipeName); | ||
resolve({ reader: transport[0], writer: transport[1] }); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters