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

Access to file system from lsp server #158189

Closed
elena-pudovkina opened this issue Aug 15, 2022 · 1 comment
Closed

Access to file system from lsp server #158189

elena-pudovkina opened this issue Aug 15, 2022 · 1 comment
Assignees

Comments

@elena-pudovkina
Copy link

Hi,
Not having vscode.workspace.fs on the server side of an extension poses quite a challenge.

One way I see to overcome this is the way anycode does it:
Add a handler to the client for fetching file contents:

client.onRequest('persisted/read', async (): Promise<string> => {
  if (!persistUri) {
     return '';
  }
  try {
     const data = await vscode.workspace.fs.readFile(persistUri);
     return decoder.decode(data);
  } catch {
     return '';
  }
});

And send a request from the server whenever you need to read files:

const raw = await this._connection.sendRequest<string>('persisted/read');

But I noticed that anycode only does this in the node runtime. Does it mean that this won’t work in the browser?
Is there a more direct way to allow the server access to the file system or will there be one in the future?

I’m asking because I’m working on migrating the Wake lsp extension to the browser. Its server is compiled from C++ to wasm and it requires access to the file system, so I'm struggling to make the transition.

@dbaeumer
Copy link
Member

@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants