Skip to content

Call generator on model save #1321

Answered by msujew
Guite asked this question in Q&A
Dec 15, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hey @Guite,

you can add a listener to the TextDocuments#onDidSave service of the language server:

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 LanguageServer service like this:

export class CustomLanguageServer extends DefaultLanguageServer {
  protected override buildInitializeResult(params: InitializeParams): InitializeResult {
     const result = super.buildInitializeResult(params);
     result.capabilities.textDocumentSync = {
       save: true,
       change: Text…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Guite
Comment options

@Guite
Comment options

Answer selected by Guite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants