neovim configuration using rocks.nvim plugin manager
at main 1.2 kB view raw
1---@class bt.util.notify 2local M = {} 3 4---@alias BtNotifyOpts {lang?:string, title?:string, level?:number, once?:boolean} 5 6---@param msg string|string[] 7---@param opts? BtNotifyOpts 8function M.notify(msg, opts) 9 if vim.in_fast_event() then 10 return vim.schedule(function() 11 M.notify(msg, opts) 12 end) 13 end 14 15 opts = opts or {} 16 if type(msg) == "table" then 17 msg = table.concat( 18 vim.tbl_filter(function(line) 19 return line or false 20 end, msg), 21 "\n" 22 ) 23 end 24 vim.notify(msg, opts.level or vim.log.levels.INFO, { 25 title = opts.title or "config", 26 }) 27end 28 29---@param msg string|string[] 30---@param opts? BtNotifyOpts 31function M.error(msg, opts) 32 opts = opts or {} 33 opts.level = vim.log.levels.ERROR 34 M.notify(msg, opts) 35end 36 37---@param msg string|string[] 38---@param opts? BtNotifyOpts 39function M.info(msg, opts) 40 opts = opts or {} 41 opts.level = vim.log.levels.INFO 42 M.notify(msg, opts) 43end 44 45---@param msg string|string[] 46---@param opts? BtNotifyOpts 47function M.warn(msg, opts) 48 opts = opts or {} 49 opts.level = vim.log.levels.WARN 50 M.notify(msg, opts) 51end 52 53return M