microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.41k stars 320 forks source link

Option to control `workspaceFolders` in `InitializeParams` #1470

Open hyangah opened 2 months ago

hyangah commented 2 months ago

Sorry for opening an issue to ask questions.

We (Go extension) are using this client library to interact with the go language server. Currently the server assumes all workspace folders have file://-scheme. In vscode, however, that's not always true - some extensions register virtual file systems and their folders can be added as workspace folders. I hoped that we could use the WorkspaceFolderMiddleware. But, I suspect this is not used when populating the workspaceFolders property of the initializeParams.

The WorkspaceFolderFeature's fillInitalizeParam calls vscode.workspace.workspaceFolders directly.

https://github.com/microsoft/vscode-languageserver-node/blob/31fe8fea47fe4ae4e0494413826d33ee898a1ee0/client/src/common/workspaceFolder.ts#L56

Are there other paths that I can use to filter out non-file type folders when building the initialize request message?

dbaeumer commented 2 months ago

The only way I can currently think of is subclassing the client and overriding fillInitializeParams and patching the workspace folders there. This being said, subclassing is generally not recommended and this might break in future versions.

The correct way would be to provide a hook via the client options.