echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
5.21k stars 189 forks source link

mini.files closes and does not reopen #1164

Closed CMOISDEAD closed 2 months ago

CMOISDEAD commented 2 months ago

Contributing guidelines

Module(s)

mini.files

Description

I've bound <leader>e to the function if not require("mini.files").close() then require("mini.files").open() end. This opens mini.files when I press these keys. However, if I exit using the q key after opening it for the first time or after resetting with <BS>, it sometimes doesn't open again when I press <leader>e or using commands. This issue doesn't happen every time, but it's not uncommon.

I'm using AstroNvim, but there doesn't seem to be any other plugin interfering with the functionality of mini.files.

The following is my mini-files.lua configuration

return {
  "echasnovski/mini.files",
  dependencies = {
    "nvim-tree/nvim-web-devicons",
    {
      "AstroNvim/astrocore",
      opts = {
        mappings = {
          n = {
            ["<Leader>e"] = {
              function()
                if not require("mini.files").close() then require("mini.files").open() end
              end,
              desc = "Explorer",
            },
          },
        },
      },
    },
  },
  specs = {
    { "neo-tree.nvim", optional = true, enabled = false },
  },
  opts = {},
}

Neovim version

v0.10.1

Steps to reproduce

  1. toggle with if not require("mini.files").close() then require("mini.files").open() end
  2. Open with the key previously bound and close with q.
  3. mini.files just doesn't open again.

Expected behavior

mini.files opens correctly no matter how I close it.

Actual behavior

Frequently, mini.files stops functioning if I exit with the q key. It requires restarting Neovim to regain functionality.

echasnovski commented 2 months ago

Thanks for the issue!

Unfortunately, I can not reproduce with the following setup:

require('mini.files').setup()
vim.keymap.set('n', '<Leader>et', function()
  if not require('mini.files').close() then require('mini.files').open() end
end)

Executing <Leader>et toggles explorer (closes if shown, opens if not shown). Also opens it if explorer was previously closed with q.


I am pretty confident that this is not an issue with 'mini.files'. If anything, it looks like this config loads 'neo-tree.nvim' which has <Leader>e mapping defined in AstroNvim. So <Leader>e toggles 'mini.files' only once after which it seems to be overridden to toggle Neo-tree.

CMOISDEAD commented 2 months ago

Thank you very much, you are right, I just tested it again with a clean version of nvim and the problem does not appear, however with a newly installed version of astronvim the problem occurs.