Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Document how to get this working with ahmedkalf/project.nvim #164

Open
metalelf0 opened this issue Aug 15, 2022 · 5 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@metalelf0
Copy link

metalelf0 commented Aug 15, 2022

Is your feature request related to a problem? Please describe.
I can't get this plugin to work with ahmedkalf/project.nvim. When I change project using its selector, the buffer list doesn't get cleared, and I still see buffers from the previous project bleeding into the new one.

Describe the solution you'd like
I'd like to have an example setup function that shows how to make the two plugins work together.

Describe alternatives you've considered
I tried my best but couldn't get it working.

Additional context
I'm setting up the two plugins as follows:

-- in init.lua
  use({
    "rmagatti/auto-session",
    config = function()
      require("auto-session").setup({
        log_level = "error",
        auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/" },
      })
    end,
  })
  use("ahmedkhalf/project.nvim")

-- in another sourced file
local status_ok, project = pcall(require, "project_nvim")
if not status_ok then
	return
end

project.setup({
	active = true,
	on_config_done = nil,
	manual_mode = false,
	detection_methods = { "pattern" },
	patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" },
	show_hidden = false,
	silent_chdir = true,
	ignore_lsp = {},
})

local tele_status_ok, telescope = pcall(require, "telescope")
if not tele_status_ok then
	return
end

telescope.load_extension("projects")
@metalelf0 metalelf0 added the enhancement New feature or request label Aug 15, 2022
@rmagatti
Copy link
Owner

You could try to setup like this. This allows for DirChangedPre and DirChanged autocmds to be handled by auto-session.

require("auto-session").setup {
    log_level = "error",
    auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/" }
    cwd_change_handling = {
      restore_upcoming_session = true,
      pre_cwd_changed_hook = nil, -- lua function hook. This is called after auto_session code runs for the `DirChangedPre` autocmd
      post_cwd_changed_hook = nil, -- lua function hook. This is called after auto_session code runs for the `DirChanged` autocmd
  }
}

Keep in mind though there is currently no guaranteed compatibility between auto-session and project.nvim. as it is not a plugin I use myself. I use rmagatti/session-lens for switching between sessions/projects.

@MikaelElkiaer
Copy link

@metalelf0 I struggled quite a bit to make these project.nvim play well together with auto-session.

I ended up creating my own plugin, utilizing auto-session in a more explicit way: https://github.com/MikaelElkiaer/reprosjession.nvim

@rmagatti
Copy link
Owner

Hey, @MikaelElkiaer that's awesome! I'm in the process of incorporating session-lens into auto-session. I use it as a project switcher, I wonder what could be improved on that flow to make it an excellent project-switching experience.

I also wonder if trying to do that ends up increasing the scope of auto-session by too much, so projects like yours are super interesting to me.

@MikaelElkiaer
Copy link

@rmagatti Thanks for your awesome work.

I ended up creating my project, because I don't want to manage my projects/sessions explicitly - any project I have is in my ~/Repositories/ dir and is a git repository. So it felt more natural to me to look those up, and then manage sessions once I've loaded a repo.

@rmagatti
Copy link
Owner

Right, that makes sense. That's a feature/idea I probably won't add to auto-session as I believe its scope should only be sessions. The merging of session-lens into auto-session is a close adjacent still since it's all about managing existing sessions, albeit in a project-y way.

Thank you for working on a related plugin! Always nice to see things like this happening!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants