I often use this in my project, to see changes :
git diff 5b80e3be314143f 3b34d24a55ab -- include/* src/* | vim -
All the lines starting with the file being changes are written like this:
diff --git a/include/behaviors/mechanical/crystal_behavior.h b/include/behaviors/mechanical/crystal_behavior.h
I would like to be able to navigate easily the files with tagbar, which uses ctags, and obtain for instance the filename, here crystal_behavior.h
.
So, I know I can use something like this in a .ctags file:
--langdef=diff
--langmap=diff:.diff
--regex-diff=/^diff --git .*b\/(.*)(\/(.*))+$/\.\. \2/d,file/
Together with this in my .vimrc
let g:tagbar_type_diff = {
\ 'ctagstype' : 'diff',
\ 'kinds' : [
\ 'd:Files',
\ ],
\ 'sort' : 0,
\ }
My problem here is what can I put in here --regex-diff=*
, to obtain filename? (I got more or less)
Is it possible to go further and also tag the hunks in each files? This is the most tricky part I cannot get.
Thank you
- Bonus question: If I read the diff directly from buffer, tagbar doesn't generate tags. Whereas if I do
git diff ...... > patch.diff
, and thenvim patch.diff
, it works.
Universal-ctags(https://ctags.io) has a built-in parser for diff imported from geany: