akinsho / bufferline.nvim

A snazzy bufferline for Neovim
GNU General Public License v3.0
3.54k stars 198 forks source link

plugin makes vim freeze with 100% load cpu #40

Closed alex-popov-tech closed 3 years ago

alex-popov-tech commented 3 years ago

Hey! First things first - thanks for the plugin, its super cool 👍

Now the issue:

Pre-conditions:

Steps:

ER: diffs should be viewed AR: nvim freezes

akinsho commented 3 years ago

Thanks for the kind words @alex-popov-tech and the steps to reproduce.

I'll try them out and see if I can trigger this bug and investigate from there.

alex-popov-tech commented 3 years ago

hey, thanks @akinsho ! I will disable it in my config for now, cause its really painful to reload nvim each time, and will be waiting for you.

Btw, it does not reproduce, if I have some file with changes, and run dv on it BEFORE opening ( so at the time of opening diff buffers it is not present in tabline )

akinsho commented 3 years ago

Tbh I use fugitive a lot and have never had that but I don't use the dv command so I've never tried it or seen it but will see. I won't get any time till tomorrow evening.

It definitely doesn't reproduce if you remove this plugin?

akinsho commented 3 years ago

Can you also post the config you use with this plugin

alex-popov-tech commented 3 years ago

i've created video with that issue https://www.dropbox.com/s/ch8iynljdzgopv3/screencast%202021-01-16%2015-29-18.mp4?dl=0 and here is the config place https://github.com/alex-popov-tech/.dotfiles/blob/master/home/.config/nvim/lua/plugins/init.lua#L73

akinsho commented 3 years ago

Thanks @alex-popov-tech that's really helpful, will dig in tomorrow. @carlitux this maybe is the same issue you mentioned in #34. Hopefully with this repro I can fix it now.

akinsho commented 3 years ago

@alex-popov-tech I've just tested this out locally and couldn't reproduce it. I figure there is something in your config or system somewhere that you might have, that is triggering this or maybe an iteration with another plugin.

I tried this with a super minimal config and it doesn't reproduce as well. I had only vim-fugitive and bufferline installed (as well my theme not necessary though) and started nvim then used Gstatus to diff vertically another file that wasn't already open.

Can you try a similar thing. Only with vim-fugitive, bufferline +/- theme and see if it still reproduces for you, if it doesn't then maybe add things back to see what triggers it 🙏🏿 .

alex-popov-tech commented 3 years ago

hey @akinsho . thanks for trying ! sure think, will try it myself also!

alex-popov-tech commented 3 years ago

i think i've found it with just fugitive and bufferline, will record a video and steps now

alex-popov-tech commented 3 years ago

here it is, i've added some comments right inside https://www.dropbox.com/s/2ipc2jga37150tk/screencast%202021-01-17%2022-16-53.mp4?dl=0

akinsho commented 3 years ago

Thanks for digging in @alex-popov-tech, in the example from the video it looks like you have other settings still enabled, I wondering if it may be a specific vim config that is causing this. Can you try only with something like

vim.cmd [[packadd! your-theme]]
vim.cmd [[packadd! vim-fugitive]]
vim.cmd [[packadd! nvim-bufferline.lua]]
vim.cmd [[colorscheme one]]
vim.cmd [[set termguicolors]]

require("bufferline").setup{}

nvim -u <path/to/above/file.lua>

be careful of packer's packer_compiled.vim you might need to remove it for this.

a few thoughts so far:

Can you try with the above config and see if you still get the same (sorry for the back and forth, I'm just still not seeing this locally and so I want to try with as little config as possible)

alex-popov-tech commented 3 years ago

i tried your file, but vim-fugitive commands are not available oO I'm not familiar with vim's native package system, do you know why it could happen?

akinsho commented 3 years ago

Hmm it could be that things in the autoload and plugin dir aren't being loaded are you using any flags like --noplugin? You can also just use packer in that file and add the 2 plugins using that

alex-popov-tech commented 3 years ago

sorry, that was packer-compiled thing yes, i can't reproduce the issue now also... mab it be some other plugin mess with bufferline? not sure what to do next, maybe manually packadd one-by-one and retry issue?

pianocomposer321 commented 3 years ago

I have a similar problem. Opening a new tab (with tabnew) causes vim to freeze.

Minimal init.lua:

vim.cmd [[packadd packer.nvim]]

require('packer').startup(function()
    use {'wbthomason/packer.nvim', opt = true}
    use {"npxbr/gruvbox.nvim", requires = {"tjdevries/colorbuddy.vim"}}
    use 'akinsho/nvim-bufferline.lua'
end)

vim.cmd "colorscheme gruvbox"
vim.cmd "set termguicolors"

require("bufferline").setup()
akinsho commented 3 years ago

@alex-popov-tech I'd suggest add only all your plugins to that file, restart and see if the bug comes back, if it does then comment out half and restart and see if it's still there if it isn't comment the tested half and uncomment the untested. You can steadily narrow it down to the specific plugin that way

If there is no bug with all your plugins installed then it must be a vim setting, in which case I would do a similar process of adding in your vim options using the same method to find at what point the bug comes back

akinsho commented 3 years ago

@pianocomposer321 what specific set of steps trigger this issue:

  1. start nvim
  2. :tabnew
  3. freezes nvim?

EDIT: just tried that and it does freeze 👍🏿, I'll dig into it after work tomorrow

pianocomposer321 commented 3 years ago

@akinsho this info may be of use to you:

FIrst of all, in case you haven't figured it out already, I omitted one step from my comment above, which is calling require("bufferline").setup(). I was rushing b/c I had somewhere I needed to be. I will edit my comment.

Second, I noticed that neovim only freezes when you haven't opened a file yet. So if you do nvim file.txt or nvim, :e file.txt, and then :tabnew after loading the file, it does not freeze. I think @alex-popov-tech has a dashboard plugin installed, so that loads a buffer on startup automatically, which means he does not get this same issue, at least that is my theory.

Hope you get this fixed soon, I really like how the plugin looks so far, and I really hope to be able to use it!

pianocomposer321 commented 3 years ago

Update: It's not just when starting neovim (i.e, when there's no file loaded at all). It seems to happen any time you run :tabnew when a [No Name] buffer is loaded.

akinsho commented 3 years ago

Ok I believe I've found a fix for the issue and just pushed a fix. Can you have a go @pianocomposer321, @alex-popov-tech and @carlitux. The issue was that I added functionality to deduplicate buffer names but [No name] buffers can't be deduplicated so the loop just hangs indefinitely. I'll have a look at that logic in more detail to see if I can refactor it but the fix should work for now 🤞🏿

alex-popov-tech commented 3 years ago

seems to be working better now, thanks a lot @akinsho ! so happy to continue using your plugin with no freezes ❤️

pianocomposer321 commented 3 years ago

@akinsho thank you sooo much! I get to uninstall barbar now!

TBH, this plugin feels like barbar redone and made 10x better and more customizable. Plus, with barbar, it would take an additional ~0.5 seconds to load the tabbar after neovim itself loads...that's just unreasonable if you ask me. With this plugin it loads instantly! I also love how this plugin manages tab pages compared to barbar.

Overall, great job! Originally I was hoping that lualine had a tabbar built in like lightline and airline do, but now I'm kinda glad it doesn't, because if they did, I probably wouldn't have checked this plugin out!

alex-popov-tech commented 3 years ago

@pianocomposer321 agree, much better, simpler, and faster than barbar!

akinsho commented 3 years ago

Thanks 😄 that's really nice to hear 🚀

pianocomposer321 commented 3 years ago

So @alex-popov-tech @akinsho can this issue be closed now?

akinsho commented 3 years ago

👍🏾 I'll close this out now thought I'd give @carlitux a chance to try this out, but we can open another issue if it regresses or didn't fix the specific issue he raised

carlitux commented 3 years ago

👍🏾 I'll close this out now thought I'd give @carlitux a chance to try this out, but we can open another issue if it regresses or didn't fix the specific issue he raised

I think it is solved I noticed the issue was when [no name] buffers but I will hire a message if the issue continues. Thank you!