neovim-session-manager icon indicating copy to clipboard operation
neovim-session-manager copied to clipboard

Load session for specific directory

Open twiddli opened this issue 1 year ago • 11 comments

Describe the problem or limitation you are having

There's a load_current_dir_session but not a load_dir_session which takes a path to a dir.

Describe the solution you'd like

A load_dir_session that takes a path to a dir.

Describe alternatives you've considered

Additional context

If you also add current_dir_session that returns pwd if a session is active or empty string otherwise, implementing features like #39 or #29 should be a breeze even outside of the plugin.

twiddli avatar Apr 17 '23 17:04 twiddli

I agree with the idea, but I would keep only load_dir_session and load current dir if the passed path is empty.

Shatur avatar Apr 17 '23 18:04 Shatur

Not sure if this warrants a new issue, but it would also be nice to have a general current_sessions or similar that returns a list of all sessions. The usecase would be to display them on something like a dashboard.

twiddli avatar Apr 17 '23 18:04 twiddli

Not sure if this warrants a new issue, but it would also be nice to have a general current_sessions or similar that returns a list of all sessions. The usecase would be to display them on something like a dashboard.

Just use this: https://github.com/Shatur/neovim-session-manager/blob/d1883f30921193f3cff4537e27514e454e0331e9/lua/session_manager/utils.lua#L114

Shatur avatar Apr 17 '23 19:04 Shatur

Just use this:

https://github.com/Shatur/neovim-session-manager/blob/d1883f30921193f3cff4537e27514e454e0331e9/lua/session_manager/utils.lua#L114

how to use this in the tmuxinator config ? $ nvim -c ':SessionManager load_current_dir_session' - open last session $ nvim -c ':SessionManager load_session /path/to/root/project/' -open last session How to open a custom session via the terminal?

pda-gb avatar Jun 27 '23 03:06 pda-gb

how to use this in the tmuxinator config ?

The function return list of all session. This is what I was asked about.

How to open a custom session via the terminal?

Use :SessionManager load_session and it will let you select a session.

Shatur avatar Jun 27 '23 07:06 Shatur

Upd.: $ nvim -c ':SessionManager [load_current_dir_session | load_last_session | load_session /path/to/root/project/]' always does one thing - it does not load the last session. Loads the last opened buffers. I opened a random file not from sessions and through this command was loaded not the specified session, but this file. I also accidentally made a mistake in init.lua and nvim did not load but crashed with an error. So in the last run there were no open buffers. So I decided to do an experiment: run nvim like this - $ nvim -c ':SessionManager load_last_session'. And since this doesn't actually load the last session, but the last open buffers(which are not there), nvim crashed out with an error.

pda-gb avatar Jun 27 '23 14:06 pda-gb

Use :SessionManager load_session and it will let you select a session.

as I already wrote, this will load the last open buffers

pda-gb avatar Jun 27 '23 14:06 pda-gb

I don't understand you.

There is no such command :SessionManager load_session /path/to/root/project/. load_session does not accept any argument. It opens session selection.

always does one thing - it does not load the last session. Loads the last opened buffers.

Not sure what you meant by that. See https://github.com/Shatur/neovim-session-manager#commands for commands and how they work.

Shatur avatar Jun 27 '23 14:06 Shatur

load_session does not accept any argument. It opens session selection

I know. Someone wrote in the comments about this application and I just tried it. But still all three options :SessionManager do load the last buffers. Now running via terminal: nvim -c ':SessionManager load_current_dir_ression' will get an error:

изображение

pda-gb avatar Jun 27 '23 14:06 pda-gb

But still all three options :SessionManager do load the last buffers.

Please, open a new issue with minimal steps to reproduce and with explanation of what you expect and what actually happens. Because I'm not sure if I understand you.

Shatur avatar Jun 27 '23 14:06 Shatur

ок

pda-gb avatar Jun 27 '23 15:06 pda-gb