Promises and async utilities for Neovim.
meanwhile.nvim started as a project for learning and experimenting with async programming in Lua and Neovim. While other Promise libraries already exist, the project grew into a fairly feature-rich implementation, so I decided to publish it for others who might find it useful.
- Generic JavaScript-like Promise implementation
- EmmyLua annotations for type checking
- Promise chaining with
:next(),:catch(), and:finally() Promise.all()for combining multiple async operations- Coroutine-based
async()/await() promisify()for adapting callback-based APIs
local meanwhile = require('meanwhile')
local Promise = meanwhile.Promise
local async = meanwhile.async
local await = meanwhile.await
local get_value = async(function()
return await(Promise.resolve(21))
end)
get_value():next(function(value)
print(value * 2) -- 42
end)Install meanwhile.nvim using your preferred Neovim plugin manager.
For example, with vim.pack:
vim.pack.add({
'https://github.com/saffr3n/meanwhile.nvim',
})Then:
local meanwhile = require('meanwhile')See :help meanwhile for the complete API documentation.
MIT