Skip to content
Timothy Madden edited this page May 13, 2024 · 2 revisions

Configuration for default tags for .diff files:

let g:tagbar_type_diff =
    \ {
    \	'ctagstype': 'diff',
    \ 	'sro': "/",
    \ 	'kinds':
    \ 	[
    \ 	    'm:modified',
    \ 	    'n:new',
    \ 	    'd:deleted',
    \ 	    'h:hunks:1'
    \ 	],
    \ 	'kind2scope':
    \ 	{
    \ 	    'n': 'newFile',
    \ 	    'm': 'modifiedFile',
    \ 	    'd': 'deletedFile'
    \ 	},
    \ 	'scope2kind':
    \	{
    \ 	    'newFile': 'n',
    \ 	    'modifiedFile': 'm',
    \ 	    'deletedFile': 'd'
    \ 	}
    \ }

But the built-in ctags parser for diff files do not look so good in Tagbar, so I here's a different ctags parser, meant for commit diffs (like the ones from git): https://gist.github.com/terminatorul/e06b3b641995f7bf614558615821a2d3 so you can see changes grouped by file path first:

image

The red minus sign is for deleted / moved files in the diff file. The config file for this should be:

let g:tagbar_type_diff =
    \ {
    \	'ctagstype': 'commitdiff',
    \ 	'sro': "/",
    \ 	'kinds':
    \ 	[
    \ 	    'c:commit',
    \ 	    'a:author',
    \ 	    'C:comitter',
    \ 	    't:timestamp',
    \	    'p:path',
    \	    's:path:1',
    \ 	    'h:hunk:1'
    \ 	],
    \ 	'kind2scope':
    \ 	{
    \ 	    's': 'changeset',
    \	    'p': 'path'
    \ 	},
    \ 	'scope2kind':
    \	{
    \ 	    'changeset': 's',
    \	    'path': 'p'
    \ 	}
    \ }
Clone this wiki locally