mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
[html] only enable embedded content support on demand
This commit is contained in:
parent
1b2478dd2b
commit
e7a9f820ad
|
@ -59,7 +59,9 @@ export function activate(context: ExtensionContext) {
|
|||
// Synchronize the setting section 'html' to the server
|
||||
configurationSection: ['html'],
|
||||
},
|
||||
|
||||
initializationOptions: {
|
||||
embeddedLanguages: { 'css': true },
|
||||
['format.enable']: workspace.getConfiguration('html').get('format.enable')
|
||||
}
|
||||
};
|
||||
|
|
|
@ -74,11 +74,13 @@ connection.onShutdown(() => {
|
|||
});
|
||||
|
||||
let workspacePath: string;
|
||||
let embeddedLanguages: { [languageId: string]: boolean };
|
||||
|
||||
// After the server has started the client sends an initilize request. The server receives
|
||||
// in the passed params the rootPath of the workspace plus the client capabilites
|
||||
connection.onInitialize((params: InitializeParams): InitializeResult => {
|
||||
workspacePath = params.rootPath;
|
||||
embeddedLanguages = params.initializationOptions.embeddedLanguages;
|
||||
return {
|
||||
capabilities: {
|
||||
// Tell the client that the server works in FULL text document sync mode
|
||||
|
@ -118,9 +120,9 @@ connection.onCompletion(textDocumentPosition => {
|
|||
let htmlDocument = htmlDocuments.get(document);
|
||||
let options = languageSettings && languageSettings.suggest;
|
||||
let list = languageService.doComplete(document, textDocumentPosition.position, htmlDocument, options);
|
||||
if (list.items.length === 0) {
|
||||
if (list.items.length === 0 && embeddedLanguages) {
|
||||
let embeddedLanguageId = getEmbeddedLanguageAtPosition(languageService, document, htmlDocument, textDocumentPosition.position);
|
||||
if (embeddedLanguageId) {
|
||||
if (embeddedLanguageId && embeddedLanguages[embeddedLanguageId]) {
|
||||
return connection.sendRequest(EmbeddedCompletionRequest.type, { uri: document.uri, version: document.version, embeddedLanguageId, position: textDocumentPosition.position });
|
||||
}
|
||||
}
|
||||
|
@ -131,9 +133,9 @@ connection.onHover(textDocumentPosition => {
|
|||
let document = documents.get(textDocumentPosition.textDocument.uri);
|
||||
let htmlDocument = htmlDocuments.get(document);
|
||||
let hover = languageService.doHover(document, textDocumentPosition.position, htmlDocument);
|
||||
if (!hover) {
|
||||
if (!hover && embeddedLanguages) {
|
||||
let embeddedLanguageId = getEmbeddedLanguageAtPosition(languageService, document, htmlDocument, textDocumentPosition.position);
|
||||
if (embeddedLanguageId) {
|
||||
if (embeddedLanguageId && embeddedLanguages[embeddedLanguageId]) {
|
||||
return connection.sendRequest(EmbeddedHoverRequest.type, { uri: document.uri, version: document.version, embeddedLanguageId, position: textDocumentPosition.position });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue