junegunn/goyo.vim

:Goyo doesn't unset winbar

Closed this issue · 2 comments

cprn commented

Hi, I'm using Lualine which is one of common winbar providers (a bar on top of the VIM window). I wanted to ask if it's intended behavior for Goyo to not unset winbar on GoyoEnter. Question spawned by this issue - there's a minimal config for Neovim there if you want to test it.

I don't know what "winbar" is and what it looks like. Is it a recent addtion to Vim/Neovim? Can you post some screenshots?

If you think it makes sense to toggle it by default, please open a pull request. Thanks.

cprn commented

Check :h winbar or try :set winbar=foobar. Winbar is a native Vim component - a bar at the top of the window, that's empty by default. Lualine dynamically updates the content of that bar - screenshot of winbar showing file type icon:

Image of Neovim with Winbar and Lualine displayed

There are reasons for hiding it in Lualine. When Lualine is installed, it dynamically updates winbar content, so it's common sense that calling lualine.hide() should hide it. Lualine developer (who suggested it should be handled by Goyo in the 1st place) confirmed it himself when closing my issue, saying:

We are resetting the options that we set when lualine is instructed to hide itself.

Clearly, they aren't resetting winbar, but since they closed the issue, I'm assuming it's for some reason intentional.

On the other hand, it is a built-in Vim setting that does display on the screen something that I assume is unwanted. So regardless of Lualine, I do think Goyo should save the content on GoyoEnter and restore it on GoyoLeave.

For now, I'm solving this in my own config with auto-commands that also handle other stuff, and closing this issue. Even if I were to submit a PR emptying and restoring winbar to Goyo, if Lualine is installed, it'd just update winbar content again before lualine.hide() takes place.

For anyone struggling with this issue, here's a bit for your init.lua:

local goyo_group = vim.api.nvim_create_augroup('GoyoGroup', {clear = true})
vim.api.nvim_create_autocmd('User', {
    group = goyo_group,
    pattern = 'GoyoEnter',
    callback = function ()
        vim.cmd('set wrap linebreak showbreak= ')
        require('lualine').hide()
        require('gitsigns').detach()
        vim.o.winbar = ''
        vim.cmd('Limelight')
    end,
})
vim.api.nvim_create_autocmd('User', {
    group = goyo_group,
    pattern = 'GoyoLeave',
    callback = function ()
        require('lualine').hide({unhide = true})
        require('gitsigns').attach()
        vim.cmd('set nowrap nolinebreak showbreak="' .. showbreakchar .. '"')
        vim.cmd('Limelight!')
    end,
})