nvim-focus / focus.nvim

Auto-Focusing and Auto-Resizing Splits/Windows for Neovim written in Lua. A full suite of window management enhancements. Vim splits on steroids!
MIT License
697 stars 34 forks source link

Error opening `plenary.nvim` popups: E592: 'winwidth' cannot be smaller than 'winminwidth' #138

Closed Leandros closed 11 months ago

Leandros commented 11 months ago

Steps to reproduce:

  1. Open nvim nvim -u vimrc (minimal vimrc below)
  2. Trigger a plenary.nvim popup with <leader>fg (<leader> is configured to be <space>)
  3. Observe the error from below.

I figured out that

autoresize = {
  minwidth = 80,
},

is the source of the error, once the minwidth is removed, no error is thrown.

Minimal Vimrc:

(using vundle for package management)

set nocompatible " be iMproved, required
filetype off     " required

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath

set background=dark

" Vundle Stuff
if has("win32") || has("win16")
    call plug#begin('$HOME/vimfiles/bundle/')
else
    call plug#begin('~/.vim/bundle')
endif

" Set mapleader before plugin loads
nnoremap <SPACE> <Nop>
let mapleader=" "
let maplocalleader=" "

if has('nvim')
    " Libraries
    Plug 'kyazdani42/nvim-web-devicons'
    Plug 'nvim-lua/plenary.nvim'               " Lua library

    Plug 'nvim-focus/focus.nvim'

    " Telescope
    Plug 'nvim-telescope/telescope.nvim', { 'branch': '0.1.x' } " Improved LSP actions
    Plug 'nvim-telescope/telescope-live-grep-args.nvim'
    Plug 'nvim-telescope/telescope-ui-select.nvim' " Use telescope as native vim select popup, required from NVIM v0.7.0
    Plug 'nvim-telescope/telescope-fzy-native.nvim'
endif

call plug#end()

" =============================================================================
" Telescope
" =============================================================================
lua << EOF
local actions = require 'telescope.actions'
local lga_actions = require("telescope-live-grep-args.actions")
require('telescope').setup {}
require('telescope').load_extension('live_grep_args')
EOF

nnoremap <leader>fg <cmd>lua require('telescope').extensions.live_grep_args.live_grep_args()<cr>

" =============================================================================
" focus.nvim
" =============================================================================
lua <<EOF
require("focus").setup({
    enable = true, -- Enable module
    autoresize = {
      minwidth = 80, -- this is the culprit, once the `minwidth` is removed, no error is thrown.
    },
})
EOF

NeoVim Version:

NVIM v0.9.2
Build type: Release
LuaJIT 2.1.1692716794

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

Run :checkhealth for more info

Full Error:

E5108: Error executing lua ...tarv/.vim/bundle/plenary.nvim/lua/plenary/popup/init.lua:408: WinEnter Autocommands for "*": Vim(append):Error executin
g lua callback: ...arv/.vim/bundle/focus.nvim/lua/focus/modules/resizer.lua:82: E592: 'winwidth' cannot be smaller than 'winminwidth'
stack traceback:
        [C]: in function '__newindex'
        ...arv/.vim/bundle/focus.nvim/lua/focus/modules/resizer.lua:82: in function 'split_resizer'
        .../home/gerstarv/.vim/bundle/focus.nvim/lua/focus/init.lua:97: in function 'resize'
        ...arv/.vim/bundle/focus.nvim/lua/focus/modules/autocmd.lua:43: in function <...arv/.vim/bundle/focus.nvim/lua/focus/modules/autocmd.lua:37>
        [C]: in function 'nvim_set_current_win'
        ...tarv/.vim/bundle/plenary.nvim/lua/plenary/popup/init.lua:408: in function 'create'
        ...arv/.vim/bundle/telescope.nvim/lua/telescope/pickers.lua:331: in function '_create_window'
        ...arv/.vim/bundle/telescope.nvim/lua/telescope/pickers.lua:401: in function 'find'
        ...p-args.nvim/lua/telescope/_extensions/live_grep_args.lua:79: in function 'live_grep_args'
        [string ":lua"]:1: in main chunk
stack traceback:
        [C]: in function 'nvim_set_current_win'
        ...tarv/.vim/bundle/plenary.nvim/lua/plenary/popup/init.lua:408: in function 'create'
        ...arv/.vim/bundle/telescope.nvim/lua/telescope/pickers.lua:331: in function '_create_window'
        ...arv/.vim/bundle/telescope.nvim/lua/telescope/pickers.lua:401: in function 'find'
        ...p-args.nvim/lua/telescope/_extensions/live_grep_args.lua:79: in function 'live_grep_args'
        [string ":lua"]:1: in main chunk
rustysec commented 11 months ago

I am also experiencing this :sob:

Leandros commented 11 months ago

@rustysec, as a workaround, you can remove minwidth until it's fixed.

rustysec commented 11 months ago

I took it out, but telescope still causes the error :man_shrugging: I haven't spent any time trying to debug it at this point, maybe I will have some time later.

willothy commented 11 months ago

I will try to look into this today, definitely important to get this working ASAP. I haven't been able to reproduce without the minwidth property set though, not sure what would be causing that.

rustysec commented 11 months ago

I'm using it inside my lazyvim config, the telescope error pops without any setup params or with the defaults minus the minwidth property. I can try to debug it a bit more this evening.

willothy commented 11 months ago

I'm using it inside my lazyvim config, the telescope error pops without any setup params or with the defaults minus the minwidth property. I can try to debug it a bit more this evening.

Sounds good, thanks!

Leandros commented 11 months ago

It's working. Brilliant! Thank you.

simonlearnscoding commented 8 months ago

I am still experiencing this issue with all popup windows does anyone have a fix for this?

cryptomilk commented 8 months ago

Do you use master? Can you provide a reproducer?

Here is a minimal config file you can modify. Save as repro.lua and run with nvim -u repro.lua. Once you have a reproducer create a tarball of the ~/.repro directory:

-- DO NOT change the paths and don't remove focus :-)
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/nvim-focus/focus.nvim", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "nvim-focus/focus.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

require('focus').setup()
-- add anything else here
Martin1887 commented 7 months ago

I have checked that the problem keeps happening in sessions created with the latest version when restoring sessions early after opening Neovim. This is more noticeable in weak processors like ARM, when typically around 5 seconds must be waited before restoring the session to not get the error.

Apart from the notification message, the result is barbar buffers are not loaded in my case.

Note: I have set lazy=false in focus.nvim configuration to load it as soon as possible.

Thanks!

cryptomilk commented 7 months ago

a) This issue is already closed as it has been fixed, if you're running into a new issue please create a new bug b) Please create a minimal reproducer, see https://github.com/nvim-focus/focus.nvim/tree/master/extras

Martin1887 commented 7 months ago

OK, I'm busy now but I will open a new issue in a couple of weeks, thanks.

xzbdmw commented 7 months ago

I've followed this advise still have same issue https://github.com/Shatur/neovim-session-manager/issues/47#issuecomment-1195760661 for me, the scrolloff is set to 0 after restore sessions.

Martin1887 commented 6 months ago

I have tried to reproduce it using the repro.lua without success, but I have read the session files and I have noticed that removing the forced set winwidth=1 of those files fixes the issue. I don't know which thing is setting them though, because it does not happen in the repro.lua file loading persisted and focus.

Thanks!

xzbdmw commented 6 months ago

I have tried to reproduce it using the repro.lua without success, but I have read the session files and I have noticed that removing the forced set winwidth=1 of those files fixes the issue. I don't know which thing is setting them though, because it does not happen in the repro.lua file loading persisted and focus.

Thanks!

Maybe you are using lazyvim? They set minwidth default option as I mentioned in readme in recent pr, you can try comment out that setting in lazyvim’s option.lua.

Martin1887 commented 6 months ago

Exactly, I use LazyVim and they set winminwidth=5 in https://github.com/LazyVim/LazyVim/commit/4c2ac6b7bfe5e39dc70b558c3ed4e3e0f84c8bab (I don't know why).

Setting it to 0 in options.lua fixes the issue, I will report it in LazyVim repository.

Thanks!