projectmgr.nvim icon indicating copy to clipboard operation
projectmgr.nvim copied to clipboard

Question: Startup/Shutdown Confusion

Open mrjbj opened this issue 1 year ago • 11 comments

hello, I'm using projectmgr under AstroVim as a recent emacs convert. I'm trying to configure such that whatever buffers I have open are first saved and then closed before switching to the new project, which will open whatever files had been open in that session before. Then, if I switch back to the previous project, current state is saved, cleared and state from old project is restored.

Is this possible? I'm trying to simulate the concept of emacs "workspaces" essentially and would appreciate any help you can provide for how to do this. Thank you.

mrjbj avatar Oct 23 '23 19:10 mrjbj

Hi! Just to make sure I'm understanding correctly, the idea is that

  • you have project A open and there are unsaved files
  • you open project B through projectmgr, which should
    • save all open buffers from project A
    • close all open buffers from project A
    • open the buffers that were left open the last time you exited project B

correct?

If so, then apart from saving the buffers, this is exactly what projectmgr does. As for saving, it wouldn't be hard to add the functionality to projectmgr (feel free to open a PR or let me know of you need help with that!), or alternatively, use something like pocco81/auto-save.nvim which will autosave your buffer any time you leave insert mode (can recommend).

charludo avatar Oct 23 '23 20:10 charludo

Thank you for your reply and sorry for not noticing you had replied earlier. I don't mind having to remember to save files in project A before switching out to project B. The behavior I see, though, is that after switching to project B, the buffers from project A are still open and show in tabs across the top. I must be missing something. Is there any config you can share with me to put in my lua/users/plugins folder to override whatever I have in there now so that this behavior works? Thanks again for your help and hope not too much trouble.

mrjbj avatar Nov 01 '23 22:11 mrjbj

Thank you for your reply and sorry for not noticing you had replied earlier. I don't mind having to remember to save files in project A before switching out to project B. The behavior I see, though, is that after switching to project B, the buffers from project A are still open and show in tabs across the top. I must be missing something. Is there any config you can share with me to put in my lua/users/plugins folder to override whatever I have in there now so that this behavior works? Thanks again for your help and hope not too much trouble.

I see, that is strange indeed!

Quick question, do you happen to cd out of your project directory at some point before closing the project / opening another project? If so that is the reason. If not - are you perhaps on WIndows? I have not been able to test this on Windows, and it could be that the path comparison projectmgr does fails there.

charludo avatar Nov 02 '23 06:11 charludo

Hello, I am on Mac, and I see the same behavior as described by @mrjbj. I use Neovide, but I see the same behavior with Neovim in the terminal.

ProHaller avatar Nov 04 '23 04:11 ProHaller

Hello, I am on Mac, and I see the same behavior as described by @mrjbj. I use Neovide, but I see the same behavior with Neovim in the terminal.

Alright, thanks for chiming in, I guess I have some bug hunting to do 😄

charludo avatar Nov 04 '23 07:11 charludo

I'm quite the beginner, so there is a high likelyhood of my config being incorrectly set to be honest. If you could provide a detailed install procedure on lazy.nvim (nvChad) I'd be happy to reset and see if that helps. Good luck. Tell me if I can do anything.

ProHaller avatar Nov 04 '23 07:11 ProHaller

I'm quite the beginner, so there is a high likelyhood of my config being incorrectly set to be honest. If you could provide a detailed install procedure on lazy.nvim (nvChad) I'd be happy to reset and see if that helps. Good luck. Tell me if I can do anything.

{
        "charludo/projectmgr.nvim",
        lazy = false,
        config = function()
            require("projectmgr").setup {
                autogit = {
                    enabled = false,
                },
                reopen = true,
            }
        end,
},

This is the relevant excerpt from my plugins.lua, also using NvChad 😄 It's probably not a config thing though, since opening/closing is not configurable AFAIK.

charludo avatar Nov 04 '23 07:11 charludo

Well that fixed my issues nicely. ^^ Thank you very much.

ProHaller avatar Nov 04 '23 15:11 ProHaller

Well that fixed my issues nicely. ^^ Thank you very much.

It did? Great to hear, but could you post your previous config so I can take a look what might have gone wrong? 😅

charludo avatar Nov 04 '23 15:11 charludo

I actually didn’t configured anything more than : { "charludo/projectmgr.nvim", lazy = false, -- important! },

I'm guessing the reopen = true is what helped.

I still get this error:

"fuzz.py" 116L, 3720B Error detected while processing VimEnter Autocommands for E5108: Error executing Lua ... hare/nvim/Lazy/projectmgr.nvim/Lua/projectmgr/manage.Lua:25: VimEnter Autocommands for "*"… script /Users/Haller/projects/fuzz/Session.vim, line 21: Vim(edit): E325: ATTEN TION stack traceback: [C]: in function 'nvim_command' … hare/nvim/Lazy/projectmgr.nvim/Lua/projectmgr/manage.Lua:25: in function 'open_project' …/share/nvim/lazy/projectmgr.nvim/Lua/projectmgr/init.lua:47: in function'startup' [string ":tua"]:1: in main chunk Press ENTER or tvDe command to continue

ProHaller avatar Nov 04 '23 23:11 ProHaller

I actually didn’t configured anything more than : { "charludo/projectmgr.nvim", lazy = false, -- important! },

I'm guessing the reopen = true is what helped.

I still get this error:

"fuzz.py" 116L, 3720B Error detected while processing VimEnter Autocommands for E5108: Error executing Lua ... hare/nvim/Lazy/projectmgr.nvim/Lua/projectmgr/manage.Lua:25: VimEnter Autocommands for "*"… script /Users/Haller/projects/fuzz/Session.vim, line 21: Vim(edit): E325: ATTEN TION stack traceback: [C]: in function 'nvim_command' … hare/nvim/Lazy/projectmgr.nvim/Lua/projectmgr/manage.Lua:25: in function 'open_project' …/share/nvim/lazy/projectmgr.nvim/Lua/projectmgr/init.lua:47: in function'startup' [string ":tua"]:1: in main chunk Press ENTER or tvDe command to continue

Thanks for letting me know! I'll have a look into both issues.

charludo avatar Nov 05 '23 06:11 charludo