Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow on large file (cursor lag) #844

Open
YuCao16 opened this issue Dec 23, 2022 · 4 comments
Open

Slow on large file (cursor lag) #844

YuCao16 opened this issue Dec 23, 2022 · 4 comments

Comments

@YuCao16
Copy link

YuCao16 commented Dec 23, 2022

Hi,

I have noticed the duplicated Issues: #107 #494 and #527 . But I don't think the problem has been solved.

  1. tagbar works fine in neovim and vim with small file (<1k loc)
  2. tagbar works fine in vim with big file (>2k loc) bug not works fine in neovim (cursor lag)
  3. Previous version of tagbar works fine in neovim with big file (eg. chxuan/tagbar, which is an archive of tagbar v2.3)
  4. Other plugins using ctags such as liuchengxu/vista.vim don't have similar problem.

tagbar v2.3 is a long history, but I still hope if someone can check where the problem is.

Anyway, tagbar was the first plugin I started with vim and it is an amazing project, thanks for your work!

PS: I'm running vim 9.0 (updatetime 4000) and nvim v0.8.1 (updatetime 250).

@raven42
Copy link
Collaborator

raven42 commented Dec 24, 2022

We have tried various methods to have tagbar run as a background task, but so far we haven't been successful in getting it to function seamlessly. There was a PR a while back that added the g:tagbar_file_size_limit option to not run tagbar on file sizes that are too large.

PRs are always welcome if someone has any expertise in the matter, but I don't have that expertise or frankly the time to rework much of this plugin at this time. I jumped in as a user of tagbar and started to help out adding smaller features and fixing bugs that I can, but this has been more of a side project that I've been able to spend time on as I have it.

So unfortunately we don't really have a good fix for this at this time. As I said though, PRs are welcome. I'll leave this issue open for the time being incase anyone with more expertise in the matter has time and the inclination to address it, but I fear we may be out of luck for this one for the time being.

@YuCao16
Copy link
Author

YuCao16 commented Dec 24, 2022

I'll leave this issue open for the time being incase anyone with more expertise in the matter has time and the inclination to address it, but I fear we may be out of luck for this one for the time being.

Agree, that's too sad.

@pidgeon777
Copy link

Maybe a rewrite of tagbar in LUA could help? A tagbar.nvim plugin.

Anyway, I also confirm the laggy cursor movements when running tagbar on big files.

Unfortunately, after running tagbar on a big file, this lag persists even switching to a small buffer, even if tagbar is not run in it, and I'm forced restarting Neovim.

Tested with Neovim v0.8.3 stable, on Windows 10.

@saraedum
Copy link

I noticed slowness when scrolling in a file and showing the current tag in lightline. It seems that this can be worked around by not calling current tag that frequently with something like this (I am a complete vimscript noob, so I am sure this could be improved quite a bit.)

function! UpdateTag() abort
  let b:current_tag = tagbar#currenttag("%s", "", "f", "nearest")
  redrawstatus!
endfunction

function! UpdateLine() abort
  if !exists("b:last_timer")
    let b:last_timer = -1
  endif

  if b:last_timer != -1
    call timer_stop(b:last_timer)
  endif
  let b:last_timer = timer_start(100, { -> UpdateTag() })
endfunction

function! UpdateCursor() abort
  if !exists("b:last_line")
    let b:last_line = line('.')
  endif
  if line('.') != b:last_line
    call UpdateLine()
    " call UpdateTag()
    let b:last_line = line('.')
  endif
endfunction

function! CurrentTag() abort
  if !exists("b:current_tag")
    let b:current_tag = "…"
  endif
  return b:current_tag
endfunction

augroup CursorMovedCommand
  autocmd!
  autocmd CursorMoved,CursorMovedI * call UpdateCursor()
augroup END

" Configure status bar
let g:lightline = {
    \ 'colorscheme': 'wombat',
    \ 'active': {
    \   'left': [ [ 'mode', 'paste' ],
    \             [ 'readonly', 'filename', 'modified', 'tags' ] ]
    \ },
    \ 'component': {
    \   'tags': '%{CurrentTag()}'
    \ },
    \ }

This won't help with the actual tag viewer but maybe something similar could be done there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants