;; fennel-ls: macro-file ; This Source Code Form is subject to the terms of the Mozilla Public ; License, v. 2.0. If a copy of the MPL was not distributed with this ; file, You can obtain one at https://mozilla.org/MPL/2.0/. (local M {}) (λ M.when-require [args ...] (let [gensyms [] errs (gensym "errors") binds (icollect [_ v (ipairs args)] (if (sym? v) (let [g (gensym)] (table.insert gensyms g) `(,g ,v)) `(xpcall (λ [] (require ,v)) (λ [err#] (table.insert ,errs (debug.traceback err#))))))] `(let [,errs [] ,(unpack binds)] (if (and ,(unpack gensyms)) (do ,...) (vim.notify (. ,errs 1) vim.log.levels.ERROR))))) (λ M.callback [args ...] `(λ ,args (do ,...) nil)) M