tagbar icon indicating copy to clipboard operation
tagbar copied to clipboard

How to only highlight/display function only

Open nikhilvijayanv opened this issue 3 years ago • 1 comments

How to modify the vim-airline and also Tagbar buffer to display only the current function name we are in instead of also including variables too

nikhilvijayanv avatar Feb 16 '21 15:02 nikhilvijayanv

I have a similar configuration for lightline and have it defined as follows:

    let g:lightline = {
			\ 'active': {
			\	'left': [['mode', 'paste', 'modified'], ['readonly', 'filename'], ['functionName']],
			\ },
			\ 'component_function': {
			\	'functionName': 'LightlineFunctionName',
			\ },
		\ }

    " ---- LightlineFunctionName() {{{2
    function! LightlineFunctionName()
	if !g:have_tagbar || &filetype =~# g:ignored_windows
		return ''
	endif
	return tagbar#currenttag("%s", "", 'f', 'nearest-stl')
    endfunction

I'm not sure if airline will behave the same way, but with lightline you can define a custom component and define that component to call a user function. Then in my user function I return the value of tagbar#currenttag("%s", "", 'f', 'nearest-stl') which will return only the function name but without the parameters.

So you could look at the airline configuration and see if there is a callback routine that can be used in the same way as lightline does.

raven42 avatar Feb 16 '21 16:02 raven42