Shatur/neovim-session-manager

The session does not load via $ nvim -c {command}

pda-gb opened this issue · 7 comments

pda-gb commented

Bug description

In the terminal, running nvim with the command :SessionManager load_current_dir_ression does not open a session from the current directory:

$ nvim -c ':SessionManager load_current_dir_ression'

Steps to reproduce

  1. I have projects proj_1, proj_2.

$ cd /path/to/root/dir/proj_1 
$ nvim
  • Open a file (file_proj_1) from this project via neo-tree.
  1. Save the session through the menu: {<leader>-Ss}. Close nvim.

$ cd /path/to/root/dir/proj_2
$ nvim
  • Open some file (file_proj_2) from this project with neo-tree.
  1. Save the session through the menu: {<leader>-Ss}. Close nvim.

  2. Then I go to the directory of the first project(proj_1).I run nvim with the command to run from the project session of the current directory.

$ cd /path/to/root/dir/proj_1
$ nvim -c ':SessionManager load_current_dir_session'

Result:
file_proj_2 is open in the buffer, the root directory in the neo-tree is /path/to/root/dir/proj_2. This is the loaded proj_2 session.

Expected behavior
A session of the first project(proj-1) must be open.

Environment

  • OS: macOS 13.4
  • latest nvim + astrovim plugins

Additional context

  • In nvim via terminal mode, the commands :SessionManager [load_current_dir_session | load_last_session | load_session] work.
  • :h -c
Shatur commented

Oh, I got it. You probably have autoload_mode = config.AutoloadMode.LastSession in your config. Could you change it to Disabled?

pda-gb commented

LastSession is the default setting? There is no autoload_mode in my config. I searched all over ~/.config/nvim/**

Shatur commented

LastSession is the default setting?

Yes, you need to override it explicitly.

pda-gb commented

I just started dealing with nvim and immediately started with astrovim. It didn't work to add a parameter change.
But I didn't do that. Because it is logically wrong.
Because the default value of the parameter is needed to run the application without specified parameters. When you need one startup with a specific parameter, it is passed in the startup command. And the default value of the parameter is overridden.
Rewriting the configuration file for a single run is a mistake.

Let's look at an example on neo-tree.
The default window position is left. But by running$ nvim -c ":Neotree position=right" it will start with a neo-vim window already open on the right.

I think the plugin is missing getting data from the nvim start command. Now I don't know if this is a bug or a missing feature. I think the developer has to decide what to do - change the tag or leave it. Or just close the issue.

Shatur commented

It didn't work to add a parameter change.

With the mentioned change it works exactly as you described in "expected behavior", I tested it.

The plugin by default autoloads last session when you just call nvim. It's done via autocmd. And you can't override it with -c because it's impossible to detect if there was something sent this way (see :h argc(), it only for files).

What you need is to disable the autoloading the way I said in your configuration and -c will work as you expect.

pda-gb commented

Unfortunately, I do not know how your plugin works with pure nvim, I have it installed through astrovim. And I did not see that the last session is loaded by default.
I understand what you are saying. Apparently I haven't figured it all out yet and I expected the same plugins to work.

Shatur commented

Show me how you installed it, I think you enabled lazy loading and that's why session is not autoloaded by default.