From 45292409715143f6a8ea32863173391324b028a4 Mon Sep 17 00:00:00 2001 From: ray-x Date: Tue, 29 Nov 2022 13:53:33 +1100 Subject: [PATCH] feature: animation on build/compile/run/test --- lua/go/asyncmake.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lua/go/asyncmake.lua b/lua/go/asyncmake.lua index 07ff0b5..caa9a9a 100644 --- a/lua/go/asyncmake.lua +++ b/lua/go/asyncmake.lua @@ -218,6 +218,23 @@ function M.make(...) else package_path = "" end + + local cmdstr = vim.fn.join(cmd, " ") -- cmd list run without shell, cmd string run with shell + local Sprite = util.load_plugin('guihua.lua', 'guihua.sprite') + local sprite + if Sprite then + sprite = Sprite:new({ + loc = 'top_center', + syntax = 'lua', + rect = { height = 1, width = 30}, + data = { 'Running '.. cmdstr }, + timeout = 5000, + hl_line = 1, + }) + else + sprite = {on_close = function() end} + end + local function on_event(job_id, data, event) -- log("stdout", data, event) if event == "stdout" then @@ -275,9 +292,12 @@ function M.make(...) efm = [[level=%tarning\ msg="%m:\ [%f:%l:%c:\ %.%#]",level=%tarning\ msg="%m",level=%trror\ msg="%m:\ [%f:%l:%c:\ %.%#]",level=%trror\ msg="%m",%f:%l:%c:\ %m,%f:%l:\ %m,%f:%l\ %m]] end + + sprite.on_close() end if event == "exit" then + sprite.on_close() if type(cmd) == "table" then cmd = table.concat(cmd, " ") end @@ -337,7 +357,6 @@ function M.make(...) end end - local cmdstr = vim.fn.join(cmd, " ") -- cmd list run without shell, cmd string run with shell -- releative dir does not work without shell log("cmd ", cmdstr) _GO_NVIM_CFG.job_id = vim.fn.jobstart(cmdstr, {