preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.12k stars 486 forks source link

How to only highlight/display function only #753

Open nikhilvijayanv opened 3 years ago

nikhilvijayanv commented 3 years ago

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

raven42 commented 3 years ago

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.