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

BUG: No buffer title when opening the preview #1405

Open
3 tasks done
subratappt opened this issue Mar 17, 2024 · 3 comments
Open
3 tasks done

BUG: No buffer title when opening the preview #1405

subratappt opened this issue Mar 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@subratappt
Copy link

subratappt commented Mar 17, 2024

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

NVIM v0.9.2

Operating System / Version

Centos 6

Describe the Bug

I am using the TAB key to preview the file, like NvimTree. Though it shows the file preview, it doesn't show the buffer title.
Also, I can go to the preview buffer and edit it. However, when I go to the previous/next buffer, the preview buffer is lost, which is unsaved.

Screenshots, Traceback

Screenshot 2024-03-17 at 5 10 19 PM
Screenshot 2024-03-17 at 5 10 58 PM

Steps to Reproduce

  1. Map TAB key to "preview"
  2. Press TAB on a file

Expected Behavior

It should show the preview of the file on the right side, with the buffer title (name of the file on the buffer line).

Your Configuration

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}

local neotree_config = {
  "nvim-neo-tree/neo-tree.nvim",
  dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
  cmd = { "Neotree" },
    config = function()
        require("neo-tree").setup({
            window = {
                mappings = {
                    ["<TAB>"] = "preview"
                }
            },
            source_selector = {
                winbar = true,
                statusline = false
            }
        })
    end
}

table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@subratappt subratappt added the bug Something isn't working label Mar 17, 2024
@pysan3
Copy link
Collaborator

pysan3 commented Mar 17, 2024

Preview is, as the name suggests, a preview window and not meant to be used for editing.
The previewed file content is only temporary generated so press enter or any other key you registered to open the file (just like when you don't have preview window opened) and you are good to go.

Regarding the name of the buffer, that [No Name] refers to the buffer that was opened there from before. The preview window is just a temporary overlay that covers 100% size of the window.
You might understand what's going on better with :Neotree float's preview window.

@subratappt
Copy link
Author

@pysan3 Thanks for your reply. When using the "use_float"=true, it is just creating the borders and "NeoTree Preview" title; otherwise the behavior is the same with "use_float"=false.
We can accept the behavior with float, because when the preview is opened in the float window, there should not be any confusion about which file you opened.
But the confusion comes with the "use_float"=false condition; it shows the preview on top of the existing buffer name (buffer tab). It should show the preview with the temp buffer name on a new buffer tab.

@pysan3
Copy link
Collaborator

pysan3 commented Mar 20, 2024

But the confusion comes with the "use_float"=false condition; it shows the preview on top of the existing buffer name (buffer tab). It should show the preview with the temp buffer name on a new buffer tab.

The buffer name you are seeing is coming from whatever tabline plugin (eg bufferline.nvim, nvim-cokeline, nougat.nvim, ...) you installed.
Those plugins should order the listed buffers (see :h 'buflisted'). If you load multiple buffers, you'll see that it is just a horizontal list of all opened buffers that has nothing to do with the current window.

To keep it short, the top line in vim is used to list all real opened buffers.
I said real here since neo-tree preview is not really opening the buffer for editing but only for previewing (:h 'nobuflisted') so this is expected.

In fact, if you use bufferline.nvim, you should see all buffer names dimmed (the color of init.lua in the first GIF in bufferline.nvim) meaning that all are not in focus.

We do not control what is shown in the tabline and tabline plugins are doing their job to show a horizontal list of all listed buffers (in your case, there's only one buffer which might make it unclear tho).

If you really don't want to see that line :h showtabline might help you.

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

2 participants