-
Notifications
You must be signed in to change notification settings - Fork 82
feat: Add custom callback variant of LspRequestCustom #663
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
base: main
Are you sure you want to change the base?
Conversation
|
I was wondering if it would be any useful to have also sync and async variant of RequestCustom (e.g. I was also thinking of providing noop Let me know what do you think and I can make those changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik a funcref needs to exist. For every call without a callback, you would have to create and empty function to pass as argument. So I think it would be better to have a separate function for this. Not a 100% sure though.
46296f8 to
aa1775c
Compare
This change adds g:LspRequestCustomCb with additional callback function parameter. Original g:LspRequestCustom calls to it with WorkspaceExecuteReply as callback function for backwards compatibility.
aa1775c to
4bc0c5b
Compare
|
@jclsn Thanks for review, I agree with you. I like approach with 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. |
|
Looks good to me, but in the end @yegappan needs to approve. |
| # Request: any | ||
| # Params: any | ||
| # Cbfunc: callback function | ||
| def g:LspRequestCustomCb(name: string, msg: string, params: any, Cbfunc: func): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the help text with some details about how to use this new function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegappan @jclsn Sure I can. I actually did bit of investigation and learning and feel in my specific usecase this should not be needed and it is language server for which I do this being wrong and anything that edits workspace should be really code action and not custom request.
Anyway I think there's still some use for this and g:LspRequestCustom. As I got more familiar with codebase I now think that rather than making both these g: it would be actually better to export in lsp.vim as in case of other functions that are used by commands.
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
methodfield).