nvim-lualine / lualine.nvim

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

Bug: Not enough room #872

Open augustocdias opened 1 year ago

augustocdias commented 1 year ago

Self Checks

How to reproduce the problem

Place a cursor on a block which the matching closing or opening is out of the viewport (ex: { and the matching } is out of the viewport) and press %

Expected behaviour

No error shown and I can navigate to the matching block.

Actual behaviour

This error is shown:

Error executing vim.schedule lua callback: ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: Vim:E36: Not enough room
stack traceback:
    [C]: in function 'nvim_win_set_option'
    ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: in function 'setter_fn'
    ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:50: in function 'set_opt'
    ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:74: in function 'set'
    ...nvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:433: in function 'refresh'
    ...nvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:343: in function <...nvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:342>⏎

Minimal config to reproduce the issue

minimal.lua:

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
    require('packer').startup({
        {
            'wbthomason/packer.nvim',
            'nvim-lualine/lualine.nvim',
            'SmiteshP/nvim-gps',
            { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' },
            'nvim-treesitter/nvim-treesitter-context',
            'andymass/vim-matchup',
        },
        config = {
            package_root = package_root,
            compile_path = install_path .. '/plugin/packer_compiled.lua',
            display = { non_interactive = true },
        },
    })
end

vim.g.matchup_matchparen_offscreen = { method = 'popup' }
vim.g.matchup_transmute_enabled = true
_G.load_config = function()
    require('nvim-treesitter.configs').setup({
        -- A list of parser names, or "all"
        ensure_installed = { 'lua' },
        matchup = {
            enable = true,
        },
    })
    require('treesitter-context').setup({
        enable = true,
        max_lines = 0,
    })
    local gps = require('nvim-gps')
    gps.setup()

    local lualine = require('lualine')

    lualine.setup({
        options = {
            icons_enabled = true,
            theme = 'auto',
            section_separators = { left = '', right = '' },
            component_separators = { left = '', right = '' },
            disabled_filetypes = {},
            globalstatus = true,
        },
        sections = {
            lualine_a = { 'mode' },
            lualine_b = { 'diff', 'branch' },
            lualine_c = {
                {
                    'filename',
                    file_status = true, -- displays file status (readonly status, modified status)
                    path = 1, -- 0 = just filename, 1 = relative path, 2 = absolute path
                },
            },
            lualine_x = {
                'encoding',
                'filetype',
                {
                    'diagnostics',
                    sources = { 'nvim_diagnostic' },
                    symbols = { error = ' ', warn = ' ', info = ' ', hint = ' ' },
                    diagnostics_color = {
                        error = 'DiagnosticError',
                        warn = 'DiagnosticWarn',
                        info = 'DiagnosticInfo',
                        hint = 'DiagnosticHint',
                    },
                    always_visible = true,
                },
            },
            lualine_y = {
                'progress',
            },
            lualine_z = {
                'location',
            },
        },
        inactive_sections = {
            lualine_a = {},
            lualine_b = {},
            lualine_c = {
                {
                    'filename',
                    file_status = true, -- displays file status (readonly status, modified status)
                    path = 1, -- 0 = just filename, 1 = relative path, 2 = absolute path
                },
            },
            lualine_x = { 'location' },
            lualine_y = {},
            lualine_z = {},
        },
        winbar = {
            lualine_a = {},
            lualine_b = {},
            lualine_c = {
                { gps.get_location },
                {
                    'filename',
                    file_status = true, -- displays file status (readonly status, modified status)
                    path = 1, -- 0 = just filename, 1 = relative path, 2 = absolute path
                },
            },
            lualine_x = { 'location' },
            lualine_y = {},
            lualine_z = {},
        },
        tabline = {},
        extensions = { 'quickfix', 'nvim-tree', 'fzf' },
    })
end
if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path })
end
load_plugins()
require('packer').sync()
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]])
shadmansaleh commented 1 year ago

Thanks for making a proper issue. It's an upstream bug. You can follow https://github.com/neovim/neovim/issues/19464

isaksamsten commented 1 year ago

Stumbled upon this issue. My workaround:

            {
              "filename",
              path = 1,
              fmt = function(filename)
                -- Small attempt to workaround https://github.com/nvim-lualine/lualine.nvim/issues/872
                if #filename > 80 then
                  filename = vim.fs.basename(filename)
                end

                if #filename > 80 then
                  return string.sub(filename, #filename - 80, #filename)
                end
                return filename
              end,
            },

If someone has the same issue while waiting for the upstream to be fixed.