echasnovski / mini.nvim

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

mini.statusline disappear when using splits #89

Closed alezunino closed 2 years ago

alezunino commented 2 years ago

Contributing guidelines

Module(s)

mini.statusline

Description

The statusline disappear when I create a split and move to it. This happens regardless the split type (horizontal or vertical). Even when closing the split the statusline does not appear.

Neovim version

0.7.0

Steps to reproduce

Expected behavior

The statusline should remain visible

Actual behavior

This is a screenshot just before moving to a split, where the statusline is ok: Before

This is a screenshot after moving to the split, where the the statusline has disappeared: After

echasnovski commented 2 years ago

Unfortunately, can not reproduce it. Neither with minimal setup, nor with my full one.

What I see in the "After" picture is an "inactive" statusline (displays full path by default). It also seems that you set up to use global statusline with laststatus = 3 along with some kind of plugin to make thin line separator instead of one with one cell height. I'd guess that somehow laststatus is set to 2 and that thin line hides the actual active statusline at that window.

alezunino commented 2 years ago

Hi, Yes, in these screenshots, laststatus = 3 and the line separator is a result of this option. I have made the statusline appear again by doing :bnext or :bprevious one. However, it disappears again after changing to a different split. I have also tried with laststatus = 2 with the same result.

This is my config: https://github.com/alezunino/dotfiles/tree/master/nvim

I have tried removing most of the plugins except telescope/lsp/cmp with no success. Do you think some of the other plugins might be interfering with mini.statusline?

thanks for this amazing plugin!!!

echasnovski commented 2 years ago

Yes, in these screenshots, laststatus = 3 and the line separator is a result of this option. I have made the statusline appear again by doing :bnext or :bprevious one. However, it disappears again after changing to a different split. I have also tried with laststatus = 2 with the same result.

This is my config: https://github.com/alezunino/dotfiles/tree/master/nvim

Without screenshots or video this will be harder to investigate. And link says "Page is not found" (seems like this is a private repo).

Does full info appear in the same place where previously there was only file path? Are you sure laststatus is set to what you expect it to be (can check with :echo &laststatus).?

It definitely seems like some other plugin or you configuration doing something unexpected. Here is what it looks like with only 'mini.statusline' loaded and vim.o.laststatus = 3 (video displays file with the whole config):

https://user-images.githubusercontent.com/24854248/174971403-d26e181b-892d-428e-b396-fb91c0d03360.mp4

By the way, here you can also see that line separator has a full cell height with laststatus = 3.

alezunino commented 2 years ago

Yes, full info appear in the same place where previously there was only file path. I have checked laststatus and its value does not change. I will try removing most of my plugins with no success so far.

The screenshots bellow are taken with laststatus = 2.

Here the statusline is ok: before

This is after moving to the upper split (statusline shows as inactive): after

This is after executing :bnext. The statusline is ok bnext

These are my nvim config files: nvimrc.zip

echasnovski commented 2 years ago

Well, that was fun. My debugging journey:

  1. I noticed was that this happened only when same buffer is displayed in both splits.
  2. This didn't seem to be caused by plugins, because I removed them and problem still persisted. Although 'andymass/vim-matchup' caused some trouble by overtaking 'mini.statusline' statusline when cursor was on some words.
  3. Problem was in 'lua/keymaps.lua', because I removed sourcing of all files and started adding them one by one.
  4. Problem was in this line: vim.cmd [[autocmd BufWinEnter,WinEnter * if &buftype == 'terminal' | silent! normal i | endif]] . Again, good old "comment half and see if problem persists". This narrowed it down to this line: if commented, problem was gone. So this finally lead me to a minimal reproducible 'init.lua':
    vim.cmd('packadd mini.nvim')
    vim.cmd [[autocmd BufWinEnter,WinEnter * if &buftype == 'terminal' | silent! normal i | endif]]
    require('mini.statusline').setup()

    Interestingly, if require('mini.statusline').setup() is put before that troublesome line or only BufWinEnter is used, everything works. So something is happening in that command that prevents autocommand from MiniStatusline to kick in and set active statusline. This checks out with observation that this only happens with same buffer (because BufEnter autocommand is not fired in this case, only WinEnter).

  5. After a bit of experimenting and reading docs, problem with this is that normal i is followed by | endif. From :h normal: This command cannot be followed by another command, since any '|' is considered part of the command. So minimal tweak can be replacing inner block with execute 'silent! normal i'. And indeed it works now. What I would really recommend is replacing this with a more suitable autocmd TermOpen * startinsert.

Thanks for an interesting use case! Closing this as the problem is not in plugin.