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

Intercept client paths #746

Closed
nojaf opened this issue Feb 13, 2021 · 4 comments
Closed

Intercept client paths #746

nojaf opened this issue Feb 13, 2021 · 4 comments

Comments

@nojaf
Copy link

nojaf commented Feb 13, 2021

I'm trying to run my language server inside a docker container.

    var _require = __webpack_require__(/*! child_process */ "child_process"),
        spawn = _require.spawn;

    return new Promise(function (resolve, reject) {
      var cp = spawn("docker", args);
      cp.stderr.on('data', function (data) {
        console.error("stderr: ".concat(data));
      });
      resolve({
        reader: cp.stdout,
        writer: cp.stdin
      });
    });

This works out but the host is on Windows and the language server is running inside Docker.
So I'm getting errors like:

stderr: [14:24:50.423 ERR] [LSP Server] HandleClientMessage - Error {"Code": -32601, "Message": "Method not found", "Data": null, "$type": "Error"} when handling notification {"Version": "2.0", "Method": "$/cancelRequest", "Params": {"Value": [[[]]], "$type": "Some"}, "$type": "Notification"}

c:\Users\nojaf\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js:5
stderr: [14:24:50.679 ERR] [LSP] PositionHandler - Getting file checker options for /workspace/c:\Users\nojaf\Projects\fantomas\src\Fantomas\RangeHelpers.fs failed

Notice: /workspace/c:\Users\nojaf\Projects\fantomas\src\Fantomas\RangeHelpers.fs
/workspace is the folder inside the container where the server is running.
c:\Users\nojaf\Projects\fantomas\src\Fantomas\RangeHelpers.fs is the client path.

Could I somehow intercept messages on the client before they go to the server to update the file path?

PS: Yes, I'm aware of devcontainers, that is not an option as I'm not running my extension in VSCode.
Please answer if file path interception is a thing here.

@dbaeumer
Copy link
Member

LanguageClientOptions#uriConverters is your friend.

@nojaf
Copy link
Author

nojaf commented Feb 17, 2021

@dbaeumer thank you for this pointer.
I noticed it is currently not used for the root path. Is that by design?

let rootPath = this._clientOptions.workspaceFolder
? this._clientOptions.workspaceFolder.uri.fsPath
: this._clientGetRootPath();

@dbaeumer
Copy link
Member

That is an oversight.

@dbaeumer
Copy link
Member

My mistake. It is by design. The rootPath is a path not a URI. The rootURI goes through the transformer. See https://github.com/microsoft/vscode-languageserver-node/blob/master/client/src/common/client.ts#L3207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants