Repository navigation
Use vim.system instead of vim.fn.system in setup guide? #2134
|
This page says:
I'm wondering what is the difference between that and this:
According to the docs:
Whereas vim.system:
I believe the latter uses uv.spawn to run the process in the background. In the case of lazy.nvim installation, is it better to block the main UI thread while the repo clones? |
Replies: 2 comments
|
Short version: So for the bootstrap snippet, In practice: if you want compatibility and don’t care about a short blocking clone during first install, |
Of course, otherwise the module is incomplete, not way neovim can use it as expected. |
Short version:
vim.fn.system()is the old Vimscript wrapper and is synchronous (blocks UI).vim.system()is the newer API and is async by default; you call:wait()if you want to block.So for the bootstrap snippet,
vim.fn.system()is simple and works everywhere (even older Neovim), but it blocks while cloning.vim.system()avoids blocking if you use the callback or checkobj:wait()later, but it’s only in newer Neovim.In practice: if you want compatibility and don’t care about a short blocking clone during first install,
vim.fn.system()is fine. If you want non‑blocking setup, you can usevim.system({...}, { text = true }, function(obj) ... end)and handle errors there, or call:wait()…