Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Expose the sync API to all client/server connections #1209

Open
rchiodo opened this issue Mar 13, 2023 · 6 comments
Open

Feature request: Expose the sync API to all client/server connections #1209

rchiodo opened this issue Mar 13, 2023 · 6 comments
Labels
feature-request Request for new features or functionality
Milestone

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Mar 13, 2023

I'm implementing this feature here:
https://github.com/microsoft/vscode-wasm/blob/main/sync-api-client/README.md
in pylance.

And it seems to me that this could be a common feature for just about every language server that uses vscode-languageserver.

Maybe something that would be exposed through a new capability.

Then on the server side you could use the new sync methods.

protected async getFileSystem() {
        return this._connection.workspace.getSyncFileSystem();
}

private _readFile(filePath: string) {
     const fs = this.getFileSystem();
    const bytes = fs.readFile(filePath);
    return this._decoder.decode(bytes, 'utf-8');
}
@dbaeumer
Copy link
Member

Currently LSp doesn't expose any FS API that roots back to the client. There are feature requests to support this and when implementing it it would be cool to provide a sync and async variant.

@dbaeumer dbaeumer added this to the On Deck milestone Mar 14, 2023
@heejaechang
Copy link
Contributor

heejaechang commented Mar 15, 2023

so, we have this issue as well - microsoft/vscode#177391

Basically, currently LSP only provides us contents for opened files. For opened files, regular file, notebook file, file on github or browser, all works as expected since we get the content/uri from LSP and we don't need to care how we get them.

But, for closed files, for regular file on disk, we can open them and read the content. and we know how to construct uri for the file ourselves that LSP client also know how to interpret. but problem is for any other cases.

For example, for closed notebook file, we are not sure how we can get contents (of each cells and metadata) and uri from them. same for files (regular or notebook) on virtual workspace or browser (basically files that are not on disks). we are not sure how we should obtain contents and uri for them.

It feels like the root cause of all this issue is that LSP only cares about open files. and feels like now it is time for LSP to provide some APIs for closed files as well.

and when it does, it would be nice if it provides both async and sync APIs for sync and async LS servers.

@heejaechang
Copy link
Contributor

Requesting each Language Server (LS) to implement handling for closed file cases (such as reading notebooks, constructing URIs according to each client's preferences for notebook cells, accessing GitHub/HTTP and creating synchronous APIs and etc) seems to be asking each LS to reinvent the wheel multiple times. Particularly, if an LSP client can manage open files, it likely indicates that they already know how to read content and creates URIs from those files.

@dbaeumer
Copy link
Member

I agree with all of this. @NTaylorMullen started to provide a FS layer inside LSP but we never got it over the finish line :-(. Help is welcome to continue the work on this.

@r3m0t
Copy link

r3m0t commented Mar 16, 2023

Would it need to be added to LSP at the same time or is it VS Code specific? @dbaeumer

@rchiodo
Copy link
Contributor Author

rchiodo commented Mar 16, 2023

I can help out on implementing this. If this was in vscode-languageserver, we wouldn't need to implement it ourselves. So we might as well implement it for everybody.

@NTaylorMullen and @dbaeumer do you want to meetup to discuss what this might look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants