-
Notifications
You must be signed in to change notification settings - Fork 255
feat: add BEFORE_FILE_MOVE
BEFORE_FILE_RENAME
events
#625
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
Conversation
@sidlatau Thanks for submitting the PR. One thing I would change is that we already have an event system that would suit this situation, and I wouldn't want to add a new Here is an example with something similar: neo-tree.nvim/lua/neo-tree/utils.lua Lines 474 to 479 in b68ebd1
And an example of that event being consumed: https://github.com/nvim-neo-tree/neo-tree.nvim/wiki/Recipes#custom-window-chooser-for-file-open-commands |
Thanks for the provided example. But the problem is, that in my case I need an event handler to call async code and wait until a callback is called - only then I need to return control to event_handlers = {
{
event = "before_file_rename",
handler = function(data)
local params = ...
lsp_client.request("workspace/willRenameFiles", params, function(err, result)
vim.lsp.util.apply_workspace_edit(result, dartls_client.offset_encoding)
end)
end,
}, Do you have any ideas on how to make it work in blocking way using events system? |
You don't actually need to do it in a blocking way. One of the keys passed in the The |
Thanks for the explanation, It finally clicked to me, how to use the events system without blocking, nice solution :) Just had an issue with events results - they are actually not returned from the |
I don't think that is true, maybe there was some other mistake that gave you that impression? If you look at the actual code change you made, the only logical difference is that if there are multiple event handlers for the same event, then it will run all of them instead of stopping at the first one that reports |
on_rename_file
hookBEFORE_FILE_MOVE
BEFORE_FILE_RENAME
events
BEFORE_FILE_MOVE
BEFORE_FILE_RENAME
eventsBEFORE_FILE_MOVE
BEFORE_FILE_RENAME
events
I removed changes in |
Sorry for the delay @sidlatau, these changes look like they will work perfectly. If they are not working for you, are you returning this from your handler? return { handled = true } |
Codecov Report
@@ Coverage Diff @@
## main #625 +/- ##
==========================================
+ Coverage 50.36% 50.50% +0.14%
==========================================
Files 47 47
Lines 6217 6164 -53
==========================================
- Hits 3131 3113 -18
+ Misses 3086 3051 -35
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Yes, I am returning Are there any actions from me needed to move forward this PR? |
No, but if the behavior it depends on is broken, then we need to fix that first so you can confirm this works as expected. |
@sidlatau If you rebase this on |
This will enable to change imports of renamed file
96b84fa
to
3146f72
Compare
This will enable to change of imports of the renamed file before the actual file rename.