summary refs log tree commit diff
path: root/.vim/lua/job.lua
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-08-30 18:19:05 +0200
committerRobert Günzler <r@gnzler.io>2021-08-31 12:41:19 +0200
commit78f496f4202b07ee0691ce5b12becd468e321535 (patch)
tree5bbef1e18476ab81477d16f70e98aa1a1ab0859e /.vim/lua/job.lua
parentaf518a14441209bc9971d1ecd95920a98496b372 (diff)
vim: strip escape codes from job output
Diffstat (limited to '.vim/lua/job.lua')
-rw-r--r--.vim/lua/job.lua7
1 files changed, 7 insertions, 0 deletions
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