馃 my neovim config:)
1
fork

Configure Feed

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

at main 45 lines 1.2 kB view raw
1if vim.g.loaded_shell then 2 return 3end 4 5vim.g.loaded_shell = true 6 7vim.api.nvim_create_user_command("Shell", function(opts) 8 opts.args = vim.trim(opts.args) 9 if #opts.args == 0 then 10 return vim.notify("shell cmd empty", vim.log.levels.WARN) 11 end 12 13 local cmdmsg = { { "command " }, { opts.args, "@markup.raw" } } 14 15 local pg = { 16 source = "shell", 17 title = "shell cmd", 18 kind = "progress", 19 percent = 0, 20 status = "running", 21 } 22 table.insert(cmdmsg, { " started" }) 23 pg.id = vim.api.nvim_echo(cmdmsg, true, pg) 24 25 vim.system({ vim.o.shell, vim.o.shellcmdflag, opts.args }, {}, function(o) 26 pg.percent = 100 27 if not o.code or o.code ~= 0 then 28 pg.status = "failed" 29 cmdmsg[3] = { (" exited with code %d SIG%d"):format(o.code, o.signal) } 30 vim.schedule(function() 31 vim.api.nvim_echo(cmdmsg, true, pg) 32 end) 33 else 34 pg.status = "success" 35 cmdmsg[3] = { (" exited succesfully"):format(o.code, o.signal) } 36 vim.schedule(function() 37 vim.api.nvim_echo(cmdmsg, true, pg) 38 end) 39 end 40 end) 41end, { 42 nargs = "*", 43 complete = "shellcmd", 44 desc = "run shell command", 45})