gennaro-tedesco / nvim-possession

📌 the no-nonsense session manager
MIT License
215 stars 7 forks source link

autoload cause double lualine in lazyvim #35

Closed phootip closed 6 months ago

phootip commented 6 months ago

I clone lazyvim starter and then add possession.lua to plugins folder with this configuration

-- stylua: ignore
return {
  { "folke/persistence.nvim", enabled = false },
  {
    "gennaro-tedesco/nvim-possession",
    lazy = false,
    dependencies = {
        {"ibhagwan/fzf-lua"},
    },
    keys = {
            { '<leader>qe', function() require("nvim-possession").list() end, silent = true, mode = { "n" }, desc = "Session Menu"},
            { '<leader>qn', function() require("nvim-possession").new() end, silent = true, mode = { 'n' }, desc = "New Session"},
            { '<leader>qu', function() require("nvim-possession").update() end, silent = true, mode = { 'n' }, desc = "Update Session"},
    },
    config = function()
        require("nvim-possession").setup({
            autoload = true,
        })
    end,
  }
}

but when I enable autoload I got double lualine when changing tab image

Here are step to reproduce

This does not happens when I disable autoload and load session normally through require("nvim-possession").list(). You can try this with this repo https://github.com/phootip/lazyvim/tree/test-possession

gennaro-tedesco commented 6 months ago

Are you sure you want to use two session plugins at the same time, namely folke/persistence.nvim and nvim-possession? They may have some conflicting behaviour, we would need to look into the code of the former to understand if it interacts with lualine even if not prompted.

I noticed that in your configuration you have lualine twice? This said, I have tried to reproduce it on my side by loading folke/persistence.nvim as well on top of mine, and I don't see such behaviour of duplicated lualine. I presume this is due to your statusline configurations (also, you're using tabs, does it also happen if loading buffers only normally? I don't exactly know how lualine interacts with tabs, perhaps it duplicates per window?)

phootip commented 6 months ago

For the first question, no, I do not want to use persistence.nvim together with nvim-possession, so I specify enabled = false for persistence.nvim. You can pay no mind to it, it's a lazyvim thing (ref),

For second question, that file is an example and do not contribute anything to my nvim because there is a return {} on line 3. this file also a part of lazyvim starter repo.

Basically I'm was reproducing this with as least commit as possible branching from lazyvim starter repo

Thank you for answering, another thing is that this double lualine go away after resizing the terminal, I tested it with window terminal and iterm2, but do not go away if I use :redraw, :redrawtabline.

gennaro-tedesco commented 6 months ago

Let us try to test it with a minimal configuration: please use the below template as repro.lua and then execute nvim -u repro.lua:

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",
        "--single-branch",
        "https://github.com/folke/lazy.nvim.git",
        lazypath,
    })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    { "craftzdog/solarized-osaka.nvim" },
    {
        "gennaro-tedesco/nvim-possession",
        dependencies = {
            "ibhagwan/fzf-lua",
        },
        config = true,
        init = function()
            local possession = require("nvim-possession")
            vim.keymap.set("n", "<leader>sl", function()
                possession.list()
            end)
            vim.keymap.set("n", "<leader>sn", function()
                possession.new()
            end)
            vim.keymap.set("n", "<leader>su", function()
                possession.update()
            end)
            vim.keymap.set("n", "<leader>sd", function()
                possession.delete()
            end)
        end,
    },
    { "nvim-lualine/lualine.nvim", config = true },
    -- add any other puglins down here
}
vim.g.mapleader = " "
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.opt.termguicolors = true
vim.cmd([[colorscheme solarized-osaka]])

where you can slightly modify the above to adapt it to your configuration options (in particular for lualine). Modularly add some configuration until you reach the problem and then we can see what is causing it.

phootip commented 6 months ago

Right now I manage to fix this with

vim.api.nvim_create_autocmd("TabEnter", { command = "set cmdheight=1" })

I might try to comeback and reproduce this with minimal config later, thank you for your time