Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly filter output with errorformat #342

Open
MarcelRobitaille opened this issue Jul 28, 2023 · 1 comment
Open

How to properly filter output with errorformat #342

MarcelRobitaille opened this issue Jul 28, 2023 · 1 comment

Comments

@MarcelRobitaille
Copy link

I have everything set up so that if I call :make and then :copen, I only see errors in my quickfix list.

vim.opt.makeprg = '~/path/to/custom/script.sh'
vim.opt.errorformat = '%f:%l:%c:\\ %tnfo\\ %n:\\ %m,%-G%.%#'

The second formatter handles this, taken from here.

I want to use Dispatch to run jobs in the background. I thought it would "just work", but if I :Make (or :Make!) and then :Copen, I see all lines output by my script, not only the errors. If I verbose set errorformat, I see:

errorformat=%f:%l:%c:\ %tnfo\ %n:\ %m,
        Last set from ~/.local/share/nvim/site/pack/packer/start/vim-dispatch/autoload/dispatch.vim line 1387

I read through :help dispatch, and thought maybe I needed to configure a compiler with its own errorformat, and that dispatch would set errorformat to what I have configured for that compiler. I read :help :CompilerSet, and created ~/.config/nvim/after/compiler/custom.vim with the contents:

CompilerSet makeprg=~/path/to/custom/script.sh errorformat=%f:%l:%c:\ %tnfo\ %n:\ %m,%-G%.%#

I also tried in two lines like in :help :CompilerSet:

CompilerSet makeprg=~/path/to/custom/script.sh
CompilerSet errorformat=%f:%l:%c:\ %tnfo\ %n:\ %m,%-G%.%#

However, if I :compiler custom, :Make, and :Copen, same thing. My errorformat is incorrectly set on line 1387 again.

How do I configure Dispatch's errorformat? I read through :help dispatch and the readme, but I only see one reference to errorformat and it doesn't really tell me how to configure it. I don't see anything about Dispatch mutating errorformat on me.

:Dispatch[!] [options] {program} [arguments]
                        Find a compiler plugin that sets 'makeprg' to
                        {program} and use its 'errorformat' to dispatch a
                        |:Make| for the given {program} and [arguments].  If
                        no compiler plugin is found, the generic format
                        %+I%.%# is used.

I tried to read the Dispatch source code, but I don't know vimscript well at all.

I am using NVIM v0.10.0-dev-737+gdf2f5e391 and Debian 11

@MarcelRobitaille
Copy link
Author

To be clear, it still correctly matches the actual errors, it just also shows non-matches. If anyone knows a better way to show non-matches, I would also accept that solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant