nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.64k stars 213 forks source link

BUG: Neo-tree Popup always has the text Neo-tree Popup #1222

Open Nikola-Milovic opened 10 months ago

Nikola-Milovic commented 10 months ago

Did you check docs and existing issues?

Neovim Version (nvim -v)

v0.9.1

Operating System / Version

Ubuntu 22.04

Describe the Bug

This text wasn't there before, not sure if a new option appeared, but this doesn't seem right

image

Screenshots, Traceback

No response

Steps to Reproduce

Do whatever command inside neotree that requires the popup

Expected Behavior

It used to look normal without the text

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" },
  keys = {
    { "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
  },
  opts = {
      close_if_last_window = true,
      enable_diagnostics = false,
      enable_git_status = false,
      use_popups_for_input = false, -- force use vim.input
      sort_case_insensitive = true,
      window = {
        mappings = {
          -- Disable neotree's fuzzy finder on `/`, it's annoying when I just want to jump to something I see
          ["/"] = "noop",
          ["#"] = "noop",
          -- Re-enable neotree's fuzzy finder using shifted letters so I can spam shift `/` + shift
          -- `f` to activate it, but still do shift `/` + `bla` to search `bla` with vim's search.
          ["/F"] = "fuzzy_finder",
          ["//"] = "fuzzy_finder", -- alt mapping, nicer?
          ["/D"] = "fuzzy_finder_directory", -- only directories
        },
        fuzzy_finder_mappings = { -- define keymaps for filter popup window in fuzzy_finder_mode
          ["<C-j>"] = "move_cursor_down",
          ["<C-k>"] = "move_cursor_up",
        },
      },
      git_status = {
        bind_to_cwd = false,
      },
      buffers = {
        bind_to_cwd = false,
      },
      filesystem = {
        use_libuv_file_watcher = true,
        bind_to_cwd = false,
        filtered_items = {
          visible = true,
          hide_dotfiles = false,
          hide_gitignored = true,
          hide_by_name = {
            "node_modules",
          },
        },
      },
    },
}

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

vim.cmd.colorscheme("tokyonight")
-- add anything else here
cseickel commented 10 months ago

I noticed that your config has:

      use_popups_for_input = false, -- force use vim.input

and yet your screenshot shows a popup being used. I tested it and confirmed that when using that config it does not use a popup. You must have plugins being loaded that you do not realize are being loaded, which is why you are seeing a popup window for input.

Can you provide a config that recreates the issue?

Nikola-Milovic commented 10 months ago

Just enabling use_popups_for_input = true, fixes it.

You can close this if this is unique to me, my config is over at my .dotfiles repo, its basically LazyVim with minimal changes

pysan3 commented 10 months ago

Please read this issue.

I can't figure out the reason but neovim's builtin cmdline (at the bottom) and noice (and possibly dressing as well? haven't tested) handles the popup differently. Builtin one discards the first line (for whatever obscure reason) so I had to add a useless line at the top to make it work.

I'm sorry but until we find out the reason, we will have to keep this workaround.

If you have an alternative solution (or suggest a different message), we are more than happy to try it out :)

It's hardcoded here.

https://github.com/nvim-neo-tree/neo-tree.nvim/blob/0f6e7acfd86b052acf78baccba04d5c61dcbbc0d/lua/neo-tree/ui/inputs.lua#L66-L68

cseickel commented 10 months ago

It seems this bug only happens if:

  1. You have vim.opt.cmdheight = 0 in your vim config
  2. You set use_popups_for_input = false in your neo-tree config
  3. You use another plugin or custom configuration that provides a pop-up window for prompts

If that is the case, we would at least need to know how 3 is implemented before we could try and fix it. If we don't have that, we might as well close the issue.

kevintraver commented 5 months ago

This might not be an issue anymore.

Maybe it got fixed in dressing.nvim?

Here is my config on neovim 0.9.5:

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 = {
  {
    "stevearc/dressing.nvim",
  },
  {
    "nvim-neo-tree/neo-tree.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "MunifTanjim/nui.nvim",
    },
    opts = {
      use_popups_for_input = false,
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.opt.cmdheight = 0
pysan3 commented 5 months ago

@kevintraver Did you read my comment?

I'm saying that the builtin popup discards the first line of the prompt.

kevintraver commented 5 months ago

Sorry, maybe I am misunderstanding.

With the config above, and this line removed:

https://github.com/nvim-neo-tree/neo-tree.nvim/blob/0f6e7acfd86b052acf78baccba04d5c61dcbbc0d/lua/neo-tree/ui/inputs.lua#L68

The input popup seems to work just fine.