0

Often times I get way too many diagnostics from my compiler (eg., things beginning note: which just provide context for the actual error), and I do not want to descend into these when I type :cn.

Can the quickfix window contain tag-like references, to be visited with ^], and can some of the compiler's diagnostic output be converted to such references? That way :cn doesn't have to descend down long lists of contextual output, but I do have the option of visiting those files easily if I need to.

For example:

In file included from /usr/include/c++/10/vector:67,
                 from test.cc:1:
/usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: ‘template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = Test; _Alloc = std::allocator<Test>]’
  653 |  vector(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~

It makes sense to me that the filename:line pair on the In file included from line should be something I could visit with ^], and I would prefer the filename:line:column associated with the note: line to be that way too, instead of being treated as the next error in the list.

5
  • The core issue, here, seems to be that your :help 'errorformat' doesn't match the output of your compiler. As-is, your question is lacking a) a reproducible example, b) the current value of errorformat, c) an indication of what compiler you use.
    – romainl
    Jun 21, 2023 at 18:28
  • More gently, I also thing the correct 'errorformat' would get you everything you want. To help you get there, it would be great if you edit to include the things romainl requested.
    – D. Ben Knoble
    Jun 21, 2023 at 18:38
  • I don't understand. I have already included sample output from a compiler. errorformat already does match the compiler output, but I want to change its behaviour to insert tag references into the quickfix window rather than syntax errors.
    – sh1
    Jun 21, 2023 at 19:19
  • It seems that an alternative error format could do better :-). Could you provide: The compiler output, the errorformat (:set errorformat?)? Jun 21, 2023 at 19:59
  • No. If the sample you have given is treated as several errors, then your efm is broken and must be fixed. There is only one valid error, there, and the rest is just context, where you should already be able to do gf, for example. Again: what compiler?, what efm? where is the reproducible example. If you want us to help you change your broken efm's behavior, the least you can do is show it to us.
    – romainl
    Jun 22, 2023 at 4:58

1 Answer 1

2

To expand on my comment…

Without sourcing any config or making any assumption about the language, compiler, etc. feeding your sample to Vim with $ vim --clean -q errorfile +copen should give something like this:

copen

where…

  • there is only one valid error (both :cn and :cN throw E553),
  • you can already do <C-w>gF or some similar command on the "In file included from" filename.

Which almost covers all your needs, with one caveat: test.cc disappeared.

Now, if your errorformat finds more than one error in the given compiler output, it should be reputed broken and you should consider fixing it. Once it is fixed, you can then fine-tune it to your requirements.

We may be able to help, but we need to see your errorformat for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.