minimap.vim icon indicating copy to clipboard operation
minimap.vim copied to clipboard

Autostarting NeoTree error. Vim(let):E716: Key not present in Dictionary: "mm_height"

Open tombh opened this issue 3 years ago • 7 comments

  • [x] I have read through the README (especially F.A.Q section)
  • [x] I have searched through the existing issues

Environment info

Arch Linux, Neovim Nightly (v0.8.0-dev+95-g07660193a)

Error

Error executing vim.schedule lua callback:
  ...packer/start/nui.nvim/lua/nui/split/init.lua:113: Vim(let):E716: Key not present in Dictionary: "mm_height"
stack traceback:
  [C]: in function 'nvim_command'
  ...packer/start/nui.nvim/lua/nui/split/init.lua:113: in function '_open_window'

Minimal config

If copied to a file called min.lua run with nvim -u min.lua to install plugins. Then run with nvim -u min.lua . (dot loads folder view) to trigger the error.

-- Ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))

-- Append temp test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- Install Packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.cmd("!git clone https://github.com/wbthomason/packer.nvim --depth 1 " .. install_path)
  vim.cmd("packadd packer.nvim")
  install_plugins = true
end

-- The minimal config to trigger bug
Message = "To trigger bug launch Nvim with a directory, eg; `nvim -u min.lua .`"
function TriggerTheBug()
  vim.notify(Message)
  vim.g.minimap_auto_start = 1
  require("neo-tree").setup({
    filesystem = {
      -- Can also be triggered if NeoTree is setup to launch on startup regardless
      hijack_netrw_behavior = "open_default",
    },
  })
end

-- Init
local packer = require("packer")
packer.init({
  package_root = test_dir .. "/pack",
  compile_path = test_dir .. "/plugin/packer_compiled.lua",
})
packer.startup(function(use)
  use("wbthomason/packer.nvim")
  use("wfxr/minimap.vim")
  use({
    "nvim-neo-tree/neo-tree.nvim",
    branch = "v2.x",
    requires = {
      "nvim-lua/plenary.nvim",
      "kyazdani42/nvim-web-devicons",
      "MunifTanjim/nui.nvim",
    },
  })

  if install_plugins then
    packer.sync()
  else
    TriggerTheBug()
  end
end)
vim.cmd('autocmd User PackerComplete ++once lua vim.notify("' .. Message .. '")')

I've had a little play in Minimap's code, and I found that guarding the beginning of function s:minimap_move solves the issue:

function! s:minimap_move() abort
  if ! has_key(s:win_info, 'mm_height')
    return
  endif
  ...

But of course I don't know if that's actually the best solution.

BTW great to see this plugin grow, I came across it a year or more ago and it's improved a lot.

Edit: I have also tried adding neo-tree to g.minimap_[close|block]* but only adding '' works. I should also point out that the docs don't make it clear what the difference is between closing and blocking.

tombh avatar May 03 '22 22:05 tombh

Thanks for bringing this to our attention! We've run into a couple of these issues of not guarding that only becomes an issue when used with other plugins. I'll put this on the list to fix up next time I have a chance.

As for close/block — I agree, the difference between those is a bit hazy. I'll add a ticket to improve the docs for those options.

ZNielsen avatar May 05 '22 15:05 ZNielsen

Great, thanks @ZNielsen 😊

tombh avatar May 07 '22 17:05 tombh

Do you mind testing this fix on branch GH-153_test_fix when you get a chance? If you are using a plugin manager, there's usually an option for which branch to use (requires an update/upgrade/pull/ect.)

Example for Plugged:

Plug 'wfxr/minimap.vim', {'branch': 'GH-153_test_fix'}

ZNielsen avatar May 11 '22 16:05 ZNielsen

Thanks for that. I just tried and it doesn't fix it, win_info isn't being populated. The bug is still triggered by that minimal config I posted above, if you want to see for yourself.

tombh avatar May 11 '22 18:05 tombh

This might be related to #140. Is there any progress on this issue?

LucasAschenbach avatar Aug 11 '22 21:08 LucasAschenbach

Nothing scientific, but I haven't seen this error in a loooong time.

tombh avatar Aug 11 '22 21:08 tombh

I've been adding some more protections around that dictionary access when I see it, glad to hear it's been getting better. I think I'm going to sit down and protect every access and see if that fixes everything.

ZNielsen avatar Aug 11 '22 23:08 ZNielsen

I appear to have run into the same or a similar error 🤔

Check list

  • [X] I have read through the README (especially F.A.Q section)
  • [X] I have searched through the existing issues

Environment info

  • OS
    • [ ] Linux
    • [X] Mac OS X
    • [ ] Windows
    • [ ] Others:

Version info

bash-3.2$ nvim --version
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.0/share/nvim"

Run :checkhealth for more info

Question / Problem and steps to reproduce

Upon opening a file with telescope, I receive the following:

E5108: Error executing lua ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:753: Vim(let):E716: Key not present in Dictionary: "mm_height"
stack traceback:
        [C]: in function 'nvim_win_close'
        ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:753: in function 'close_windows'
        ...ck/packer/start/telescope.nvim/lua/telescope/pickers.lua:1488: in function 'on_close_prompt'
        ...acker/start/telescope.nvim/lua/telescope/actions/set.lua:134: in function 'run_replace_or_original'
        ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'run_replace_or_original'
        ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'run_replace_or_original'
        ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:338: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

Upon opening a file directly from the command line and attempting to navigate in the file, I receive:

Error detected while processing CursorMoved Autocommands for "<buffer=3>"..function <SNR>65_handle_autocmd[26]..<SNR>65_minimap_move:
line    8:
E716: Key not present in Dictionary: "mm_height"

After I press enter to dismiss the error, the minimap does not respond to my navigation within the file. Let me know if there's any other information I can include that would be helpful!

ethowitz avatar Nov 01 '22 16:11 ethowitz

I am also seeing this error after I run :PlugInstall and then attempt to close the installation log window:

image

It also appears to break the syntax highlighting for the buffer I'm returning to.

masaeedu avatar Dec 07 '22 16:12 masaeedu

I'm also seeing this with netrw. If I open netrw with :Explore and then close the window with :q, I get:

Error detected while processing FocusGained Autocommands for "<buffer=1>"..function <SNR>31_handle_autocmd[26]..<SNR>31_minimap_move:
line    8:
E716: Key not present in Dictionary: "mm_height"
E116: Invalid arguments for function float2nr

and then movements are broken in the window I return to.

pete-may avatar Jun 06 '23 00:06 pete-may