vim-dispatch icon indicating copy to clipboard operation
vim-dispatch copied to clipboard

Not jumping to errors listed within the Qf buffer

Open symbolix opened this issue 6 months ago • 3 comments

I'm having the following problem:

When I run this: :Dispatch gcc %:p -o build/%:t:r

I get the errors listed in the QF buffer,

 1 || /home/me/dev/vixrc-project-config/template_dispatch_typeA/src/main.c:20:5: warning: implicit declaration of function ‘my_request’ [-Wimplicit-function-declaration]¬
 2 ||    20 |     my_request(1);¬
 3 ||       |     ^~~~~~~~~~¬
 4 || /home/me/dev/vixrc-project-config/template_dispatch_typeA/src/main.c:22:36: error: expected ‘;’ before ‘sleep’¬
 5 ||    22 |     printf("Processing data ...\n")¬
 6 ||       |                                    ^¬
 7 ||       |                                    ;¬
 8 ||    23 |     sleep(5);¬

But then none of the commands are working :cnext, :cprev etc. I can't jump to the errors based on the error message in the QF buffer.

Upon further inspection using the following command: :echo getqflist()

I can see that the QF is not constructed in the correct way, no filename or other information is present (line numbers etc.)

[{'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '/home/me/dev/vixrc-project-config/template_dispatch_typeA/src/main.c: In function ‘main’:'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '/home/me/dev/vixrc-project-config/template_dispatch_typeA/src/main.c:20:5: warning: implicit declaration of function ‘my_request’ [-Wimplicit-function-declaration]'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '   20
|     my_request(1);'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '      |     ^~~~~~~~~~'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '/home/me/dev/vixrc-project-config/template_dispatch_typeA/src/main.c:22:36: error: expected ‘;’ before ‘sleep’'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '   22 |     printf("Processing data ...\n")'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '      |                                    ^'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '      |                                    ;'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '   23 |     sleep(5);'}, {'lnum': 0, 'bufnr': 0, 'end_lnum': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'module': '', 'type': 'I', 'end_col': 0, 'col': 0, 'text': '      |     ~~~~~                           '}]

Seems like :cnext and :cprev jump to next and previous lines within the Qf buffer, but not setting the cursor in the source file buffer.

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jul 21 2025 01:39:54) Included patches: 1-1573 OS: Linux Mint 22.1 x86_64 Running in the terminal (Alacritty), no tmux

symbolix avatar Jul 28 '25 00:07 symbolix

What I have notice is that if I set up this:

:set makeprg=gcc\ -fno-diagnostics-color\ -fno-diagnostics-show-caret\ %:p\ -o\ %:p:r
:compiler gcc

and run :Make, I get this:

src/main.c|18 col 1 error| unknown type name ‘define’
src/main.c|18 col 12 error| expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
|| /home/me/dev/vixrc-project-config/template_tmux_independent/src/main.c: In function ‘main’:
src/main.c|22 col 5 warning| implicit declaration of function ‘my_request’ [-Wimplicit-function-declaration]

and this creates a clean, navigable Qf. I can do :cnext and :cprev, hit enter on the error line and can go to the error in my source code, etc.

But I don't get that clean output with :Dispatch. I get all those || in there ...

|| /home/me/dev/vixrc-project-config/template_tmux_independent/src/main.c:18:1: error: unknown type name ‘define’¬                                                                                                                       || /home/me/dev/vixrc-project-config/template_tmux_independent/src/main.c:18:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant¬
|| /home/me/dev/vixrc-project-config/template_tmux_independent/src/main.c: In function ‘main’:¬
|| /home/me/dev/vixrc-project-config/template_tmux_independent/src/main.c:22:5: warning: implicit declaration of function ‘my_request’ [-Wimplicit-function-declaration]¬

... which I think is what breaking the errorformat parsing.

symbolix avatar Jul 28 '25 10:07 symbolix

Providing the following flag to the :Dispatch command, seems to fix the issue: -compiler=gcc. But I'm not sure why this is needed.

symbolix avatar Jul 28 '25 11:07 symbolix

I guess makeprg needs to be set for parsing to work?

slpng avatar Sep 04 '25 19:09 slpng