lsp icon indicating copy to clipboard operation
lsp copied to clipboard

feat: Add custom callback variant of LspRequestCustom

Open blami opened this issue 3 months ago • 3 comments

This change allows to provide callback function to custom requests.

Builds on #640 to accommodate scenarios where response is needed from server but cannot be handled by custom handler (as there's no method field).

blami avatar Sep 21 '25 17:09 blami

I was wondering if it would be any useful to have also sync and async variant of RequestCustom (e.g. RequestCustomAsync). With these two virtually any missing/niche functionality can be done as custom request.

I was also thinking of providing noop g:LspRequestCustomReply (basically same as WorkspaceExecuteReply except scope) that can be used if caller does not care about response.

Let me know what do you think and I can make those changes.

blami avatar Sep 21 '25 17:09 blami

@jclsn Thanks for review, I agree with you. I like approach with *Cb() callback variant. Also I changed the non-callback to just call callback variant providing original WorkspaceExecuteReply so that if logic ever changes fix will be in single place.

The only other option I can think of is to have variadic argument and check for emptyness but that feels too fragile and obscure to me.

Let me know what do you think now.

blami avatar Sep 30 '25 13:09 blami

Looks good to me, but in the end @yegappan needs to approve.

jclsn avatar Sep 30 '25 13:09 jclsn