Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asynchronize vim script?

Tags:

vim

I use vim to do some slowly operations after file saved, those operations let my vim got stuck, so I wondering is there some asynchronize method to make those operations run in background?

Demo:

autocmd BufWritePost *.js call DoSomeTing()

function! DoSomeThing()
    " some operations really slow
endfunction
like image 249
Ethan Zhang Avatar asked Apr 30 '12 15:04

Ethan Zhang


1 Answers

You can use one of the more powerful language bindings (such as Python) to start a new thread and do your work in there. This is generally a really difficult task to get right, however. Also you really must not attempt to modify any vim structures or call any vim functions from these other threads - nothing in the vim core is thread safe.

like image 95
Tom Whittock Avatar answered Oct 21 '22 11:10

Tom Whittock