nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
5.92k stars 462 forks source link

Bug: require('lualine').hide() doesn't hide winbar with Goyo #1122

Closed cprn closed 8 months ago

cprn commented 10 months ago

Self Checks

How to reproduce the problem

I apologize, it's not an isolated issue - it only happens when I use Goyo with Lualine but I'm asking for help because I can't put my finger on it. I tried to make it as easy to analyze as possible.

  1. use provided init.lua
  2. open any plain text file and call :Goyo.

Expected behaviour

Both statusline and winbar gone.

Actual behaviour

Only statusline gone.

Minimal config to reproduce the issue

-- { 1. install some add-on manager (I'm using Lazy):
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system {
        'git',
        'clone',
        '--filter=blob:none',
        'https://github.com/folke/lazy.nvim.git',
        '--branch=stable',
        lazypath,
    }
end
vim.opt.rtp:prepend(lazypath)
-- }

-- { 2. install Goyo, Limeligth, Lualine and configure some winbar
require('lazy').setup({
    {'junegunn/limelight.vim'},
    {'junegunn/goyo.vim'},
    {'nvim-lualine/lualine.nvim', dependencies = {'nvim-tree/nvim-web-devicons', 'SmiteshP/nvim-navic'}, opts = {
        options = {theme = 'onedark', disabled_filetypes = {statusline = {'NvimTree'}}},
        winbar = {lualine_c = {{'filetype', icon_only = true}, 'navic'}}
    }},
}, {})
-- }

-- { 3. add Goyo config to autohide lualine
local goyo_group = vim.api.nvim_create_augroup('GoyoGroup', {clear = true})
vim.api.nvim_create_autocmd('User', {
    desc = 'Enable LimeLight on GoYo enter',
    group = goyo_group,
    pattern = 'GoyoEnter',
    command = 'Limelight|lua require("lualine").hide()',
})
vim.api.nvim_create_autocmd('User', {
    desc = 'Disable LimeLight on GoYo leave',
    group = goyo_group,
    pattern = 'GoyoLeave',
    command = 'Limelight!|lua require("lualine").hide {unhide=true}',
})
-- }

Additional information

Again, sorry it's not an isolated case - I'll totally get it if you just close it. I'm having trouble isolating what's the root cause. I'm guessing it has something to do with Goyo using two extra vertical buffers to center the main buffer but I can't figure it out.

Screenshot: image

Sam-programs commented 9 months ago

you also need to set winbar to nothing with goyo for some reason?

         vim.api.nvim_create_autocmd('User', {
            desc = 'Enable LimeLight on GoYo enter',
            group = goyo_group,
            pattern = 'GoyoEnter',
            callback = function()
               require("lualine").hide()
               vim.o.winbar = ''
               -- also hide tabline
               -- vim.o.showtabline = 0
               vim.cmd('Limelight')
            end,
         })
         vim.api.nvim_create_autocmd('User', {
            desc = 'Disable LimeLight on GoYo leave',
            group = goyo_group,
            pattern = 'GoyoLeave',
            callback = function()
               -- reshow tabline
               -- vim.o.showtabline = 2
               require("lualine").hide({unhide = true})
               vim.cmd('Limelight!')
            end,
         })
cprn commented 9 months ago

Yup, when I unset vim.o.winbar it works - thank you very much!

My issue is solved but can you tell if it's a bug in Lualine or Goyo? Should I leave the ticket open?

Sam-programs commented 9 months ago

I think it might be intended in Goyo to allow a winbar, because it might help with locating scopes with something like novic. U can ask if it's intended there in an issue if u want.

I am also not really sure why lualine doesn't unset winbar.

Sam-programs commented 9 months ago

I think i found the issue lualine doesn't reset an option,if it didn't set it before. And the global winbar option is set implicitly whenever lualine sets the local option.

~~If i understand what is happening correctly: The global winbar stays when goyo creates new tab. lualine doesn't reset the global winbar because it doesn't know that set it before by setting the window local option in the other tab.~~ Never mind i am not sure why the global option transfers to the Goyo window.

shadmansaleh commented 8 months ago

We are resetting the options that we set when lualine is instructed to hide itself. I don't think we should be touching options that we haven't set. This issue should probably be fixed on goyos side. I'm also not really sure why it's happening though.