Skip to content

[Cross-Plugin Bug] If a buffer is opened via the other plugins(fzf-lua), it will not be a listed buffer, thus cannot be shown by bufferline.nvim #321

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

Closed
nyngwang opened this issue Apr 26, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@nyngwang
Copy link

nyngwang commented Apr 26, 2022

Continued from #305 (comment). While the double-[No Name] has been resolved, I forgot to test the interaction between neo-tree and fzf-lua. I found that:

  1. If the buffer is opened via fzf-lua, the result of command set buflisted? is nobuflisted. This means that the problem is not from bufferline.nvim, it is working correctly: ignore not-listed buffers.
  2. It only happened when I started a new nvim process and wanted to create the first window/buffer for the file selected via fzf-lua, as the two DEMO below. No such problem if there is already a buffer loaded/listed in the background.
  3. By testing without neo-tree.nvim, I cannot reproduce this bug using fzf-lua's minimal config.

So it seems that the interaction between neo-tree.nvim and fzf-lua will somehow cause a buffer loaded with nobuflisted, thus the buffer is not displayed by bufferline.nvim.


UPDATE:

In my experiments, these combinations didn't work as expected: (all testings use hijack_netrw_behavior = 'open_default', if I change it to 'open_current' the problem of 2. will disappear, i.e. the buffer from fzf-lua selection will get listed.)

  1. position = 'float' + fzf-lua selection: While the file did get listed, the current buffer becomes (the only) [No Name].
bufferline_bug_2.mov
  1. position = 'left' / 'right' + fzf-lua selection: The current buffer did load the file content, but its set buflisted? returns nobuflisted.
bufferline_bug_1.mov
@nyngwang nyngwang changed the title When open a file in a buffer selected by fzf-lua, the buffer is not listed thus cannot be shown by bufferline.nvim If I open a file in a buffer via other plugins(fzf-lua), the buffer will not be listed thus cannot be shown by bufferline.nvim Apr 26, 2022
@nyngwang nyngwang changed the title If I open a file in a buffer via other plugins(fzf-lua), the buffer will not be listed thus cannot be shown by bufferline.nvim [Integration Bug] If a buffer is opened via the other plugins(fzf-lua), it will not be listed thus cannot be shown by bufferline.nvim Apr 26, 2022
@nyngwang nyngwang changed the title [Integration Bug] If a buffer is opened via the other plugins(fzf-lua), it will not be listed thus cannot be shown by bufferline.nvim [Cross-Plugin Bug] If a buffer is opened via the other plugins(fzf-lua), it will not be listed thus cannot be shown by bufferline.nvim Apr 26, 2022
@nyngwang nyngwang changed the title [Cross-Plugin Bug] If a buffer is opened via the other plugins(fzf-lua), it will not be listed thus cannot be shown by bufferline.nvim [Cross-Plugin Bug] If a buffer is opened via the other plugins(fzf-lua), it will not be a listed buffer, thus cannot be shown by bufferline.nvim Apr 26, 2022
@cseickel
Copy link
Contributor

cseickel commented Apr 26, 2022

I have a few comments:

  1. Can you please provide a minimal init that includes Neo-tree? It could still be the interaction from another plugin that is causing your issue.
  2. The combination of using a netrw hijack along with position="float" and then opening a fzf window is a little ridiculous. Just don't do that. The "float" position is really for using Neotree as a fuzzy finder, it shouldn't be left open all the time or used as part of a netrw hijack.
  3. In the second video, was Neotree the focused window when you initiated fzf? If it was, try focusing the other window first and then initiating fzf.

I find it very unlikely that Neo-tree could be affecting whether or not another buffer is listed or not. There is a slim possibility that it could affect which buffer is focused though, especially if Neo-tree was the focused window when you tried to open a new buffer.

@nyngwang
Copy link
Author

nyngwang commented Apr 26, 2022

  1. Can you please provide a minimal init that includes Neo-tree? It could still be the interaction from another plugin that is causing your issue.

Can. But it takes some time since my config is a little bit messy. I might post it and tag you later.

  1. [...] The "float" position is really for using Neotree as a fuzzy finder, it shouldn't be left open all the time or used as part of a netrw hijack.

Got it. Now I'm using open_current with 'left'. The reason I use fzf-lua for opening files is that the current Filter Pattern is relatively slower than it, and it cannot search the file I want using this syntax:

  1. In the second video, was Neotree the focused window when you initiated fzf? If it was, try focusing the other window first and then initiating fzf.

This works. I moved back to 'left'+fzf-lua using this workaround based on your hint:

vim.keymap.set('n', '<C-G>', function ()
  if vim.bo.filetype == 'neo-tree' then
    vim.cmd('wincmd l')
  end
  require('fzf-lua').files()
end, NOREF_NOERR_TRUNC)

@Shatur
Copy link

Shatur commented May 1, 2022

Have the same behavior with Telescope.

@cseickel
Copy link
Contributor

cseickel commented May 1, 2022

I was able to recreate this with Telescope with :Neotree buffers to show me what is listed, and files opened via Telescope when I am currently on a Neo-tree window will have this problem. I can fix this now.

@cseickel
Copy link
Contributor

cseickel commented May 1, 2022

This should be fixed now in main

@cseickel cseickel added the bug Something isn't working label May 2, 2022
@Shatur
Copy link

Shatur commented May 2, 2022

Works for me.

@nyngwang
Copy link
Author

nyngwang commented May 5, 2022

@cseickel I think the bug has not been fixed? I mean, is it possible to correctly switch to the selected file/window by fzf-lua when the command is called upon current neo-tree (floating) window?

@cseickel
Copy link
Contributor

cseickel commented May 5, 2022

@nyngwang It works fine for me. I am testing with Telescope instead of fzf, but I wouldn't expect that to make a difference. Are you still having a problem opening files as listed when a Neotree float was the prior window?

@nyngwang
Copy link
Author

nyngwang commented May 5, 2022

@cseickel Sorry for my late reply, sleeping. I have tested removing these checks but the results are the same as in the video in this thread. Let me test it again now.

  vim.keymap.set('n', '<C-G>', function ()
    -- Close neo-tree before running fzf-lua
    if vim.bo.filetype == 'neo-tree' then vim.cmd('wincmd h') end
    require('fzf-lua').files()
  end, NOREF_NOERR_TRUNC)
  vim.keymap.set('n', '<Leader>gs', function ()
    if vim.bo.filetype == 'neo-tree' then vim.cmd('wincmd h') end
    require('fzf-lua').git_status()
  end, NOREF_NOERR_TRUNC)

update: Yes, still the same result. But anyway I think we can stop here because I have migrated to left instead of float. This is more useful since I can keep the tree open. And even with the current situation(the current buffer after fzf-lua selection will become [No Name]), the selected file is always listed, which is acceptable for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants