I am writing a VIM plugin in Python. I would like to be able to run a function that would wait for events in the background and update a buffer when needed, without freezing the whole window. Is that possible?
I tried running a separate thread using the threading
module, which didn't help. The changes in the buffer are reflected only when the function returns (and the blocking thread terminates).
Clarification: I have a function that may take dozens of seconds to return the updates. I need to update one of the buffers with the returned data (and call the function again).
How do I call it "asynchronously" and not have the window frozen? If I can do it by spanning a separate process, how do I set up the IPC?
Another update: What if I create a temp file, have a separate process write to it, and watch for FileChangedShell
as suggested here to automatically refresh it?
(If there is no "it's not going to work" answer and no better ideas in my mind, I will try this in a while and update with results).