Open noklam opened 3 weeks ago
The 2-step process is just a quirk from the fact the playground tries to make it possible to call a command from any server, without knowing up front what those commands are called.
Assuming that your command does not require any arguments, you should be able to replace the value of command
in
https://github.com/openlawlibrary/pygls/blob/a40a3c3ad18943503e29cbd61586545974d4dbc8/.vscode/extensions/pygls-playground/package.json#L29-L32
with the id of your custom command (the string you pass to @server.command()
). It should then be possible to call your command directly from the VSCode command palette.
However, if your command does take arguments or you need to process the return value in any way then I don't think you can avoid writing some TS! 😅
I found this section in the docs: https://pygls.readthedocs.io/en/v0.10.2/pages/advanced_usage.html#commands The entrypoint is registered in the playground: https://github.com/openlawlibrary/pygls/blob/a40a3c3ad18943503e29cbd61586545974d4dbc8/.vscode/extensions/pygls-playground/package.json#L29-L32
While this works fine, it involves two steps to execute a command:
Is there a way to combine these into 1 step? The alternative is using the VSCode API directly https://code.visualstudio.com/api/extension-guides/command, but it has some downside:
It seems like this is possible by modifying https://github.com/openlawlibrary/pygls/blob/a40a3c3ad18943503e29cbd61586545974d4dbc8/.vscode/extensions/pygls-playground/src/extension.ts#L244-L248, is there any tradeoff implementing this on the server side instead of client?