preservim / tagbar

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

Cursor flickering momentarily when autosaving with CursorHold,CursorHoldI, only when Tagbar is enabled #829

Closed eq0cdk closed 1 year ago

eq0cdk commented 1 year ago

The cursor flickers whenever autosaving is triggered with CursorHold or CursorHoldI. This doesn't happen when Tagbar is disabled. I'm using the vwtags.py script from https://github.com/vimwiki/utils/blob/master/vwtags.py.

This is extremely distracting and disorienting. Please fix this problem.

Tagbar disabled: https://user-images.githubusercontent.com/101584995/184339114-faa79806-1469-4067-a7e1-68e447fd79ab.mp4

Tagbar enabled: https://user-images.githubusercontent.com/101584995/184339145-3076d11d-7f8a-4773-ab29-4fd5559eb174.mp4

My vimrc:

"# Automatically save vimwiki files, only if buffer was changed
autocmd CursorHold,CursorHoldI *.wiki,*.md :silent! update

"# Tagbar
let g:tagbar_type_vimwiki = {
      \   'ctagstype':'vimwiki'
      \ , 'kinds':['h:header']
      \ , 'sro':'&&&'
      \ , 'kind2scope':{'h':'header'}
      \ , 'sort':0
      \ , 'ctagsbin':'~/.vim/vwtags.py'
      \ , 'ctagsargs': 'default'
      \ }

"## Main settings
let g:tagbar_compact = 2
let g:tagbar_singleclick = 1
let g:tagbar_width = 40
let g:tagbar_silent = 1
let g:tagbar_no_status_line = 1
let g:tagbar_highlight_follow_insert = 1
let g:tagbar_sort = 0
let g:airline#extensions#tagbar#enabled = 0 

"## Autostart tagbar when opening wiki page
autocmd VimEnter *.wiki,*.md nested :call tagbar#autoopen(1)
autocmd BufEnter *.wiki,*.md :silent! w!

"## Autostart tagbar when opening new tab
autocmd TabNew * nested :call tagbar#autoopen(1)

"## Hide colon
autocmd FileType tagbar highlight Colon guifg=Black ctermfg=Black
autocmd FileType tagbar syn match Colon / : header/

"## Other
autocmd FileType tagbar highlight TagbarHighlight guifg=Blue ctermfg=Blue
autocmd FileType tagbar highlight TagbarType guifg=Black ctermfg=Black
raven42 commented 1 year ago

Unfortunately there is not really anything that can be done for this based on the current design. When the file is changed in the file system, that triggers the update to the file for tagbar and to do that, it first needs to jump to the tagbar window to refresh the contents while ctags is re-run on the now updated file. The only thing I know of to fix this would be to rewrite the parsing portion of tagbar and have that run in a background process as a separate thread. This has been discussed in more detail in #532 but the methods we've tried thus far haven't really worked as a true background process. With vim 9 out now, things like that may change, but I currently don't have an environment to test vim 9.

Closing this and we can track this under #532