none
How to send a change event to LSP server? RRS feed

  • Question

  • Hi guys,

    I'm writing a LSP server and clinet in VS code. I use lsp4j to implement the LSP server and use the npm package vscode-languageclient to implement the client.

    In the client, I use a FileSystemProvider to get the file conent, because I need a customize scheme. Below is code slice of the implementation of FileSystemProvider::readFile:

    if (path) {
        return fs.readFileSync(path);
    }

    As you see, I get the data from an existing file directly. Then I use following code to open the uri:

    vscode.commands.executeCommand('vscode.open', vscode.Uri.Parse(a-customize-uri));

    Certainly the the file system provider could work and the file could be opened, but no change event emitted when I modify the content. Which means when I change the file content in the editor, no jsonRPC communication between client and server. I could get the change event when the file is saved (FileChangeType.Changed), but that's not what I want.

    If I don't use FileSystemProvider, just open the file directly:

    vscode.commands.executeCommand('vscode.open', vscode.Uri.file(abs-path))
    

    Everything goes well, language client could send the change event correctly.

    I also tried to add middle ware (didOpen, didSave, didChange) in the client options, but still could not work. Also, when I don't use the FileSystemProvider, the middle ware could be called correctly.

    So I guess whether FileSystemProvider could interest the change event in the editor?

    Not sure whether I describe my question clearly, but any comment would be appreciated.

    Thanks!

    Wednesday, March 25, 2020 8:13 AM

All replies

  • Hi Claude,

    Welcome to MSDN forum.

    According to your description, I suppose this issue is about VS Code and our forum is to discuss Visual Studio IDE issues. If you encounter some issue in VS Code, please report it in the Stack Overview tagged visual-studio-code forum or GitHub repository, and start a new thread for a more professional help.

    If you have any more Visual Studio General Questions in the future, please feel free to post in the forum.

    Sorry for any inconvenience and thanks for your understanding.

    Best Regards,

    Anna

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, March 25, 2020 9:39 AM