diff options
| author | Robert Günzler <r@gnzler.io> | 2022-02-08 23:57:02 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-02-08 23:57:02 +0100 |
| commit | 2e3ebd3b8e2fbf88e1681ef52248ad3de1c4a251 (patch) | |
| tree | 26cd71a54ddc00cca0b723b156588a4ed68cd6a9 /.vim/lua/job.lua | |
| parent | d85ee2757c412e2df4d45d23d7fef88d0c66cfe0 (diff) | |
vim: markdown: add link preview helper
Diffstat (limited to '')
| -rw-r--r-- | .vim/lua/job.lua | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/.vim/lua/job.lua b/.vim/lua/job.lua index 9a235c4..c14e978 100644 --- a/.vim/lua/job.lua +++ b/.vim/lua/job.lua @@ -7,7 +7,7 @@ local M = { } --create a new job and register ---@return /usr/local/share/nvim/site/pack/packer/start/plenary.nvim/lua/plenary/job.lua +--@return ~/.local/share/nvim/site/pack/packer/start/plenary.nvim/lua/plenary/job.lua function M.jobstart(opts) opts = opts or {} @@ -19,14 +19,20 @@ function M.jobstart(opts) title = opts.command end + if opts.populate_quickfix == nil then + opts.populate_quickfix = true + end + opts.enable_recording = true -- enable job:result() - opts.on_exit = vim.schedule_wrap(function(j, _) + opts.on_exit = vim.schedule_wrap(function(j, code) spinner.on_progress('end', j.pid, j.pid) spinner.on_exit(nil, nil, j.pid) - local lines = j:result() - if not lines or #lines < 1 then + local lines + if code == 0 then + lines = j:result() + else lines = j:stderr_result() end @@ -35,12 +41,13 @@ function M.jobstart(opts) lines[i] = (lines[i]):gsub(string.char(27) .. '[[0-9;]*m', '') end - vim.fn.setqflist({}, ' ', { - title = title, - lines = lines, - }) - - if #lines > 0 then + -- only show quickfix if there is output + if opts.populate_quickfix and #lines > 0 then + vim.bo.errorformat = '%m' + vim.fn.setqflist({}, 'r', { + title = title, + items = lines, + }) vim.api.nvim_command('doautocmd QuickFixCmdPost') end |