From 78f496f4202b07ee0691ce5b12becd468e321535 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Mon, 30 Aug 2021 18:19:05 +0200 Subject: vim: strip escape codes from job output --- .vim/lua/job.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '.vim') diff --git a/.vim/lua/job.lua b/.vim/lua/job.lua index 7261d24..b6c34f7 100644 --- a/.vim/lua/job.lua +++ b/.vim/lua/job.lua @@ -26,10 +26,17 @@ function M.jobstart(opts, _wrap_command_for_presentation) if not lines or #lines < 1 then lines = j:stderr_result() end + + -- strip ansi terminal color codes + for i = 1, #lines do + lines[i] = (lines[i]):gsub(string.char(27) .. '[[0-9;]*m', '') + end + vim.fn.setqflist({}, ' ', { title = title, lines = lines, }) + if #lines > 0 then vim.api.nvim_command('doautocmd QuickFixCmdPost') end -- cgit 1.4.1