I want g:tagbar_show_visibility
be set to '0'
for Python files as there's no public/protected/private in Python. How can I configure Vim this way?
How to disable showing visibility symbols in Tagbar for a specific filetype?
507 Views Asked by planetp AtThere are 2 best solutions below

To perform the operation manually execute this:
:TagbarClose
:let g:tagbar_show_visibility = 0
:TagbarOpen
you can add the following line to your vimrc to make it automatically:
au BufRead *.py :let g:tagbar_show_visibility = 0
The autocommand (au) execute a command on specific events. With this particular example it sets the variable to 0 for buffers .py at the moment vim read them.
EDIT
My solution does not work very well. Since the variable g:tagbar_show_bisibility is global. The Tagbar plugin seems to read it when TagbarOpen is called. So a better approach will be to use a function to open Tagbar, say TagbarOpen2 or something. The function would check the filetype of the current buffer and set the visibility variable accordingly.
EDIT2
I made a script that will set the visibility each time you enter a buffer. Then to refresh the Tagbar I use TagbarToggle two time in a row. It is a little anoying, but its the best I got. Maybe you could come up with something better avoiding the flikering if you spend some time.
Please share if improve this script.
function! TagbarUpdate()
if (&ft == 'tagbar')
return
endif
let g:tagbar_show_visibility = 1
if (&ft == 'python')
let g:tagbar_show_visibility = 0
endif
exec ":TagbarToggle"
exec ":TagbarToggle"
endfunction
au! BufEnter * :call TagbarUpdate()
You can customize
ctagsargs
for a particular filetype, makingctags
not output the 'visibility' information for tags in the first place, e.g.:The important bit here is the
--fields
option, which specifies the fields to be included for each tag.