-- @runtimes lua54 --- 演示:Neovim 插件的纯逻辑 + stub vim。 local M = {} local function greeting(vim, name) vim.api.nvim_out_write("hello " .. name .. "\n") return "hello " .. name end --- @return table { text = string } function M.run(log) log = log or print local output = {} local vim = { api = { nvim_out_write = function(text) output[#output + 1] = text end, }, } local text = greeting(vim, "Ada") log(("text=%s writes=%d"):format(text, #output)) return { text = text } end if not ... then M.run() end return M