Shatur / neovim-session-manager

A simple wrapper around :mksession.
GNU General Public License v3.0
530 stars 52 forks source link

CurrentDir not working for lazy nvim setup #113

Closed aniketgm closed 8 months ago

aniketgm commented 8 months ago

Bug description I'm using lazy.nvim, I've set the options for autoload_mode as CurrentDir, but when I open nvim in the folder, the session of current directory does not load. What am I doing wrong here ?

Steps to reproduce This is my very simple config:

  {
    "Shatur/neovim-session-manager",
    dependencies = { "nvim-lua/plenary.nvim" },
    opts = {
      autoload_mode = require('session_manager.config').AutoloadMode.CurrentDir,
    }
  },
  1. cd into the folder for which you already have session saved -- cd <folder>
  2. Open neovim -- The session for this current folder does not open automatically. I have to manually open using SessionManager load_current_dir_session

Expected behavior

Screenshots/Gif

wezterm-gui_9obxCSq5uF

Environment

Additional context NA

Shatur commented 8 months ago

I suspect that LunarVim intercepts the current folder and loads its session instead. But I don't use LunarVim, so I can't say for sure.

aniketgm commented 8 months ago

LunarVim does not have any session by default. Just the "alpha-nvim" screen that can be seen in the gif that loads at startup. Do you think that might be causing the issue ? Let me try disabling . 'alpha-nvim'

Shatur commented 8 months ago

Yes, I suspect that the welcome screen could cause the issue.

aniketgm commented 8 months ago

Gif after disabling alpha-nvim: (Still issue is there. I think alpha-nvim is not the issue). P.S. Thank you for the quick responses, much appreciated. thank you.

wezterm-gui_Pr1PlurFxh

Shatur commented 8 months ago

Weird. Can't reproduce the issue on my side with the exact same configuration. For me it loads the session from the current working directory from which I opened neovim...

I can only suggest to try disabling plugins and see if any plugin causes an issue. Other possibility could be your packet manager. Maybe it loads the plugin too late and the session doesn't load up? You can check it by placing the plugin in ~/.config/nvim/pack/plugins/start/ and put the following file as ~/.config/nvim/plugin/session_manager.lua:

session_manager.setup({
  autoload_mode = require('session_manager.config').AutoloadMode.CurrentDir,
})
aniketgm commented 8 months ago

So, it seems setting opts does not work. Because, there I'm setting the options for the config beforehand. opts is passed to config. For packer, I believe the options are required to be set inside the setup. What lazy gives is flexibility to set options and call config around those. But anyways, eventually, the following worked,

{
  "Shatur/neovim-session-manager",
  dependencies = { "nvim-lua/plenary.nvim" },
  config = function()
    require('session_manager').setup({
      autoload_mode = require('session_manager.config').AutoloadMode.CurrentDir,
    })
  end
},