mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Cleanup lsp sample
This commit is contained in:
2
lsp-multi-root-sample/.vscode/launch.json
vendored
2
lsp-multi-root-sample/.vscode/launch.json
vendored
@ -5,7 +5,7 @@
|
||||
{
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"name": "Launch Extension",
|
||||
"name": "Launch Client",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||
"stopOnEntry": false,
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
|
||||
import {
|
||||
createConnection, TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity,
|
||||
ProposedFeatures, InitializeParams, DidChangeConfigurationNotification, CompletionItem, CompletionItemKind, TextDocumentPositionParams
|
||||
ProposedFeatures, InitializeParams, DidChangeConfigurationNotification, CompletionItem,
|
||||
CompletionItemKind, TextDocumentPositionParams
|
||||
} from 'vscode-languageserver';
|
||||
|
||||
// Create a connection for the server. The connection uses Node's IPC as a transport.
|
||||
@ -51,32 +52,32 @@ connection.onInitialized(() => {
|
||||
});
|
||||
|
||||
// The example settings
|
||||
interface Settings {
|
||||
interface ExampleSettings {
|
||||
maxNumberOfProblems: number;
|
||||
}
|
||||
|
||||
// The global settings, used when the `workspace/configuration` request is not supported by the client.
|
||||
// Please note that this is not the case when using this server with the client provided in this example
|
||||
// but could happen with other clients.
|
||||
const defaultSettings: Settings = { maxNumberOfProblems: 1000 };
|
||||
let globalSettings: Settings = defaultSettings;
|
||||
const defaultSettings: ExampleSettings = { maxNumberOfProblems: 1000 };
|
||||
let globalSettings: ExampleSettings = defaultSettings;
|
||||
|
||||
// Cache the settings of all open documents
|
||||
let documentSettings: Map<string, Thenable<Settings>> = new Map();
|
||||
let documentSettings: Map<string, Thenable<ExampleSettings>> = new Map();
|
||||
|
||||
connection.onDidChangeConfiguration(change => {
|
||||
if (hasConfigurationCapability) {
|
||||
// Reset all cached document settings
|
||||
documentSettings.clear();
|
||||
} else {
|
||||
globalSettings = <Settings>(change.settings.lspMultiRootSample || defaultSettings);
|
||||
globalSettings = <ExampleSettings>(change.settings.lspMultiRootSample || defaultSettings);
|
||||
}
|
||||
|
||||
// Revalidate all open text documents
|
||||
documents.all().forEach(validateTextDocument);
|
||||
});
|
||||
|
||||
function getDocumentSettings(resource: string): Thenable<Settings> {
|
||||
function getDocumentSettings(resource: string): Thenable<ExampleSettings> {
|
||||
if (!hasConfigurationCapability) {
|
||||
return Promise.resolve(globalSettings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user