echasnovski / mini.nvim

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

Error on second navigation using mini.files when mapped to `-` #972

Closed mblarsen closed 2 weeks ago

mblarsen commented 2 weeks ago

Contributing guidelines

Module(s)

mini.files

Description

I've configured mini.files to open on - (minus).

This works great the first time but second time I get the error below.

If I us a different map, e.g. gf there's no issues.

   Error  17:16:05 msg_show.lua_error     min /min             
   Error  17:16:06 msg_show.lua_error Error executing vim.schedule lua callback: ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:2100: attempt to compare number with nil
stack traceback:
    ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:2100: in function 'is_modified_buffer'
    ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:2277: in function 'window_update_border_hl'
    ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:2246: in function 'window_set_view'
    ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:1558: in function 'explorer_refresh_depth_window'
    ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:1321: in function 'explorer_refresh'
    ...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:714: in function <...al/share/nvim-homebrew/lazy/mini.nvim/lua/mini/files.lua:680>

This is my setup (Lazy.nvim)

return {
  {
    "echasnovski/mini.nvim",
    config = function()
      require("mini.basics").setup {
        options = {
          basic = true,
          extra_ui = true,
          win_borders = "single",
        },
        silent = true,
      }
      require("mini.ai").setup()
      require("mini.diff").setup()
      vim.keymap.set("n", "ghp", require("mini.diff").toggle_overlay)
      require("mini.files").setup {
        mappings = {
          go_in_plus = "<cr>",
        },
      }
      vim.keymap.set("n", "-", require("mini.files").open, { desc = "Open parent directory" })
      require("mini.surround").setup()
      require("mini.operators").setup()
    end,
  },

Neovim version

0.10.0

Steps to reproduce

  1. Open mini.files by pressing -
  2. mini.files opens and I navigate to a file L
  3. from that file I press - again
  4. small mini.files opens with no content and the error

Expected behavior

No response

Actual behavior

Small mini.files window opens with nothing in it

image
echasnovski commented 2 weeks ago

Thanks for the issue!

Unfortunately, I can not reproduce. I have no error and everything opens as expected after pressing - again inside a file opened from the explorer.

There are some issues with reproduction steps:

If it doesn't work with - but works with some other mapping, there seems to be a conflicting mappings. What does :nmap - show?

mblarsen commented 2 weeks ago

Hmm, after running with only mini and nothing else I don't have the issue either. Sorry for the alarm, must be some conflicting plugin.

Regarding L I was flipping back from L and and <cr> (coming from oil.nvim) so wrote up the wrong steps 👐

mblarsen commented 2 weeks ago

FYI -- the conflict was https://github.com/m4xshen/hardtime.nvim

Even when disabling hardtime in minifiles it still fails.

return {
  "m4xshen/hardtime.nvim",
  wnabled = true,
  dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
  opts = {
    disabled_filetypes = { "minifiles" },
    restriction_mode = "hint",
  },
}
echasnovski commented 2 weeks ago

Thanks for the follow up!

This is somewhat expected because 'hardtime.nvim' treats - as special key. So might be doing something not compatible with MiniFiles.open().