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

Adapt to lazy load session_lens of auto-session #742

Closed
Saafo opened this issue May 16, 2023 · 4 comments · Fixed by #745
Closed

Adapt to lazy load session_lens of auto-session #742

Saafo opened this issue May 16, 2023 · 4 comments · Fixed by #745
Labels
enhancement New feature or request

Comments

@Saafo
Copy link
Contributor

Saafo commented May 16, 2023

Feature description

Currently, auto-session start with configuring session_lens, so that if we start with auto-session, it will load telescope immediately and will cost about 40 ms at startup.

Now, it fixed this issue by rmagatti/auto-session#231, and we can configure this for auto-session:

  session_lens = {
    load_on_setup = false,
  },

to avoid loading telescope at start, which will only cost about 1ms even if we load auto-session at startup.

This issue is suggesting adding the configuration above to the auto-session config. And if possible, I can create a pr for it.

Besides, I wonder whether we should call require("auto-session").setup_session_lens() at some point before using session-lens

Additional information

No response

@Saafo Saafo added the enhancement New feature or request label May 16, 2023
@ayamir
Copy link
Owner

ayamir commented May 16, 2023

We have lazy loaded the auto-session itself with SessionSave, SessionRestore and SessionDelete cmds.

cmd = { "SessionSave", "SessionRestore", "SessionDelete" },

It does't affect the startuptime.

@Saafo
Copy link
Contributor Author

Saafo commented May 16, 2023

We have lazy loaded the auto-session itself with SessionSave, SessionRestore and SessionDelete cmds.

Oh I mean, if someone (like me) enable the auto-session by lazy=false, then the configuration helps.

@ayamir
Copy link
Owner

ayamir commented May 16, 2023

Use a command to wrap these two lua functions maybe the simplest way.

return function()
	require("auto-session").setup({
		log_level = "info",
		auto_session_enable_last_session = true,
		auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/",
		auto_session_enabled = true,
		auto_save_enabled = true,
		auto_restore_enabled = true,
		auto_session_suppress_dirs = nil,
		session_lens = {
			-- If load_on_setup is set to false, one needs to eventually call `require("auto-session").setup_session_lens()` if they want to use session-lens.
			load_on_setup = false,
			theme_conf = { border = true },
			previewer = false,
		},
	})

	vim.api.nvim_create_user_command("SessionLenShow", function()
		require("auto-session").setup_session_lens()
		require("auto-session.session-lens").search_session()
	end, { nargs = 0 })
end

I will create a pr for it if acceptable.

@Saafo
Copy link
Contributor Author

Saafo commented May 16, 2023

LGTM!

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

Successfully merging a pull request may close this issue.

2 participants