yioneko / vtsls

LSP wrapper for typescript extension of vscode
Other
541 stars 8 forks source link

Can plugins handle a custom request? #200

Open mcchrish opened 2 months ago

mcchrish commented 2 months ago

So it used to that vue language server handles the request volar/client/findFileReference to find reference of a SFC vue file. https://github.com/volarjs/volar.js/blob/ea92d55c03a82bf4515da82384aeb339425b5874/packages/language-server/protocol.ts#L17

So far since vue language tools move to be a typescript plugin I haven't figured out how to make the same functionality work. As a start, I figure this request should now be passed to the vtsls server however it does not have a handler for such request. I assume the typescript plugin should then be responsible for it?

I guess the question here is if this issue should be handle by this server, or the plugin upstream.

yioneko commented 2 months ago

Currently the server does not support TS plugin to register new LSP request handler so request like volar/client/findFileReference won't be handled. The limitation is somehow inherited from the vscode extension, which does not expose api for other extensions to register new language features to get handled by the TS plugin.

But for the specific "find file references" feature, we do not need a handler for volar/client/findFileReference to make it work. An existing command typescript.findAllFileReferences of this server should automatically recognize references of Vue file if the vue plugin activated. However, there is a minor issue in the original extension to prevent the command from returning references of Vue file: https://github.com/microsoft/vscode/issues/200511 https://github.com/microsoft/vscode/blob/1b071a84f9ba6aaaecfc4a0e154a019daf5fc0da/extensions/typescript-language-features/src/languageFeatures/fileReferences.ts#L37-L41

The vue vscode extension workaround this by monkey patching the typescript extension and we might need a similar solution here.

yioneko commented 2 months ago

Since commit 0834c3bf9350542ffbce2cca382ee2befb40e9ba, you could just use command typescript.findAllFileReferences for the references of vue file.

yioneko commented 3 weeks ago

Related https://github.com/microsoft/vscode/issues/218275