I use machines with vim 8.1.2269
I have a common situation where I cross compile on one machine and debug on another. As such I'll generate an error.err file to use with vim's quickfix feature. I have some vimscript that manipulates the quickfix list to my liking, however one hiccup that I haven't been able to fix is changing the path/filename associated with a quickfix item.
If I have an error.err file that looks like
/home/users/me/foo.cpp:156:18: error: no matching function for call to 'foo'
if (!foo(m, n, A,
^~~~~~~~~~~~~~~~~~~~
/home/users/me/foo.hpp:242:6: note: candidate template ignored: could not match 'vector<type-parameter-0-0>' against 'float *'
bool foo(int64_t m, int64_t n, const std::vector<fp>& A,
^
/home/users/me/foo.cpp:156:18: error: no matching function for call to 'foo'
if (!foo(m, n, A,
^~~~~~~~~~~~~~~~~~~~
/home/users/me/foo.hpp:242:6: note: candidate template ignored: could not match 'vector<type-parameter-0-0>' against 'double *'
bool foo(int64_t m, int64_t n, const std::vector<fp>& A,
^
Then :cfile
loads the the quickfix list as expected, and I'm able to add/delete/change items with getqflist() and setqflist(). In particular I can add items with
let l:list = getqflist()
call add(l:list, {'filename' : '/somepathhere/'})
call setqflist(l:list)
However, the list returned by getqflist() does not contain any information on the filename /home/users/me/foo.cpp
or /somepathhere/
:
[{'lnum': 156, 'bufnr': 2, 'col': 18, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' error: no matching function for call to ''foo'''},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' if (!foo(m, n, A,'},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' ^~~~~~~~~~~~~~~~~~~~'},
{'lnum': 242, 'bufnr': 3, 'col': 6, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' note: candidate template ignored: could not match ''vector<type-parameter-0-0>'' against ''float *'''},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'bool foo(int64_t m, int64_t n, const std::vector<fp>& A,'},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' ^'},
{'lnum': 156, 'bufnr': 2, 'col': 18, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' error: no matching function for call to ''foo'''},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' if (!foo(m, n, A,'},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' ^~~~~~~~~~~~~~~~~~~~'},
{'lnum': 242, 'bufnr': 3, 'col': 6, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' note: candidate template ignored: could not match ''vector<type-parameter-0-0>'' against ''double *'''},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'bool foo(int64_t m, int64_t n, const std::vector<fp>& A,'},
{'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': ' ^'},
{'lnum': 0, 'bufnr': 5, 'col': 0, 'pattern': '', 'valid': 0, 'vcol': 0, 'nr': 0, 'type': '', 'module': '', 'text': ''}]
getqflist({'all' : 0})
also doesn't return any filename info. My question is where did this data go, and how can I change it?
'bufnr': 2
and'bufnr': 3
has that information... Try:echo bufname(2)
and:echo bufname(3)
to see that it should match yourfoo.cpp
andfoo.hpp
...:ls
output (they're unlisted) and included that information there too. Cheers!