-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
How to intercept ["workspace/executeCommand"] to use a custom lua function instead of sending to LS? #858
Comments
I don't really understand what you're asking. These questions generally belong on discourse, but I'll try to ask some clarifying questions here. What do you mean "intercepting a command"? We send the request for executeCommand here and process the handler here You can override either of these.
This is a broad question? Are you asking with regards to your snippet or the language client in general? I would just file the work you have as a PR and it can be discussed there. |
Default handler give this code action menu nvim.mp4if I accept any of the first three, the debug log will be similar to these lines
unfortunately, these commands aren't server side they are supposed to be a wrapper around a local function which will execute the expected action What I meant by intercepting was, do something different
Ok, my bad since, it is the first time I use lua to something, and I'm not that comfortable, will do it later. |
I think this relates to neovim/neovim#14115 Intercepting the handler for workspace/executeCommand would be too late, because that's called once the server responds with a result for a executed command. You'd have to override the function used to send commands to the handler or override the code actions |
This is what I would recommend doing in the case of this client |
Can you detail what do you mean? I did not understand |
I think you should be able to do something like this: local orig_execute_command = vim.lsp.buf.execute_command
vim.lsp.buf.execute_command = function(command)
if command.command == '_ltex.addToDictionary' then
-- ...
else
orig_execute_command(command)
end
end
|
Hmm ok, I got it. If I have two LSP connected (e.g. texlab and ltex-ls complete each other functionalities) this would cause any problem? |
Closing in favor of continued discussion in #863 |
Hi, I’m trying to contribute / use this ltex-ls with neovim built-in client, so far, this is what I could achive alone ltex.lua.
This LS has a nonstandard way to implement 3 actions at the client side with involves intercepting these commands from workspace/executeCommand
(_ltex.addToDictionary)
(_ltex.disableRules)
(_ltex.hideFalsePositives)
These actions are generated by the default handler of code action, what I want is when they happen instead of trying to communicate with LS, execute my custom function.
Regarding coding in lua / neovim lsp client config, what I can improve, there is a better solution for anything already done?
Regards,
Lucas
The text was updated successfully, but these errors were encountered: