🪴 my neovim config:)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

plugin: add msg to shell cmd

robin b7d5e909 209b929c

+23 -3
+23 -3
config/plugin/shell.lua
··· 6 6 7 7 vim.api.nvim_create_user_command("Shell", function(opts) 8 8 opts.args = vim.trim(opts.args) 9 - if #vim.trim(opts.args) == 0 then 10 - return 9 + if #opts.args == 0 then 10 + return vim.notify("shell cmd empty", vim.log.levels.WARN) 11 11 end 12 12 13 + local cmdmsg = { { "command " }, { opts.args, "@markup.raw" } } 14 + 15 + local pg = { 16 + kind = "progress", 17 + title = "cmd", 18 + percent = 0, 19 + status = "running", 20 + } 21 + table.insert(cmdmsg, { " started" }) 22 + pg.id = vim.api.nvim_echo(cmdmsg, true, pg) 23 + 13 24 vim.system({ vim.o.shell, vim.o.shellcmdflag, opts.args }, {}, function(o) 25 + pg.percent = 100 14 26 if not o.code or o.code ~= 0 then 27 + pg.status = "failed" 28 + cmdmsg[3] = { (" exited with code %d SIG%d"):format(o.code, o.signal) } 15 29 vim.schedule(function() 16 - vim.notify(('command "%s" exited with code %d SIG%d'):format(opts.args, o.code, o.signal), vim.log.levels.WARN) 30 + vim.api.nvim_echo(cmdmsg, true, pg) 31 + end) 32 + else 33 + pg.status = "success" 34 + cmdmsg[3] = { (" exited succesfully"):format(o.code, o.signal) } 35 + vim.schedule(function() 36 + vim.api.nvim_echo(cmdmsg, true, pg) 17 37 end) 18 38 end 19 39 end)