somebody
somebody

Reputation: 227

Executing a function in Vim in the background

I'm using a plugin to compile LaTeX from within Vim (more specifically MacVim). For larger projects, the compilation process might take around 30 seconds during which the editor is frozen - the compilation is initiated by the command "call TeX_RunLatex()".

Is it possible in Vim to run "call TeX_RunLatex()" (or any other function) asynchronously in the background?

Upvotes: 0

Views: 1639

Answers (2)

OhleC
OhleC

Reputation: 2950

While it's true that vim doesn't natively support asynchronous operations, I find Tim Pope's vim-dispatch plugin quite useful, especially for your usecase, since it offers a variation of the :make command. It uses a variety of "adapters" for dispatching async operations; my favorite is the tmux adapter.

Upvotes: 0

Ingo Karkat
Ingo Karkat

Reputation: 172738

Asynchronous execution is a much-longed-for feature in Vim, but difficult because Vimscript is inherently single-threaded. The Execute external programs asynchronously under Windows page lists approches for an external command (which the vim-latex plugin ultimately executes). There are also several plugins that aid with that (listed under "See Also" on that page).

I'd recommend to raise this request with the plugin's author, as it is very hard to achieve this without modifying the plugin itself.

Upvotes: 3

Related Questions