Something went wrong. Try again.
🪴 my neovim config:)
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445if vim.g.loaded_shell then returnend
vim.g.loaded_shell = true
vim.api.nvim_create_user_command("Shell", function(opts) opts.args = vim.trim(opts.args) if #opts.args == 0 then return vim.notify("shell cmd empty", vim.log.levels.WARN) end
---@type [string,(string|integer)?][] local cmdmsg = { { "command " }, { opts.args, "@markup.raw" } }
local pg = { source = "shell", title = "shell cmd", kind = "progress", status = "running", } table.insert(cmdmsg, { " started" }) pg.id = vim.api.nvim_echo(cmdmsg, true, pg)
vim.system({ vim.o.shell, vim.o.shellcmdflag, opts.args }, {}, function(o) if not o.code or o.code ~= 0 then pg.status = "failed" cmdmsg[3] = { (" exited with code %d SIG%d"):format(o.code, o.signal) } vim.schedule(function() vim.api.nvim_echo(cmdmsg, true, pg) end) else pg.status = "success" cmdmsg[3] = { (" exited succesfully"):format(o.code, o.signal) } vim.schedule(function() vim.api.nvim_echo(cmdmsg, true, pg) end) end end)end, { nargs = "*", complete = "shellcmd", desc = "run shell command",})