-
Hello, is there a LSP interface where a generator can be called automatically as soon as a source model is saved in the editor? This would perfectly complete the replacement of the old Xtext-based DSL's behavior. Thanks for your assistance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @Guite, you can add a listener to the services.shared.workspace.TextDocuments.onDidSave((event) => {
// `event.document.uri` contains the uri of the saved document
}); Note that in order to fire this event, you need to adjust the capabilities of the language server. You need to create an override of the export class CustomLanguageServer extends DefaultLanguageServer {
protected override buildInitializeResult(params: InitializeParams): InitializeResult {
const result = super.buildInitializeResult(params);
result.capabilities.textDocumentSync = {
save: true,
change: TextDocumentSyncKind.Incremental
};
return result;
}
} We have an open issue to make this a bit easier: #1272 |
Beta Was this translation helpful? Give feedback.
Hey @Guite,
you can add a listener to the
TextDocuments#onDidSave
service of the language server:Note that in order to fire this event, you need to adjust the capabilities of the language server. You need to create an override of the
LanguageServer
service like this: