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

Config clean up #339

Closed
cameronr opened this issue Aug 5, 2024 · 6 comments
Closed

Config clean up #339

cameronr opened this issue Aug 5, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@cameronr
Copy link
Collaborator

cameronr commented Aug 5, 2024

I'm thinking about trying to revamp the config to something like:

local AutoSessionConf = {
  enabled = true, -- Enables/disables auto creating, saving and restoring
  session_root_dir = vim.fn.stdpath "data" .. "/sessions/", -- Root dir where sessions will be stored
  auto_save_enabled = true, -- Enables/disables auto save feature
  auto_restore_enabled = true, -- Enables/disables auto restore feature
  auto_create_enabled = true, -- Enables/disables auto creating new sessions. Can take a function that should return true/false if a session should be created or not
  suppress_dirs = nil, -- Suppress session restore/create in certain directories
  allowed_dirs = nil, -- Allow session restore/create in certain directories
  enable_last_session = false, -- Enables/disables the "last session" feature
  use_git_branch = false, -- Include git branch name in session name
  lazy_delay_enabled = true, -- Enables/disables Lazy delay feature
  log_level = "error", -- Sets the log level of the plugin (debug, info, error)
  bypass_session_save_file_types = nil, -- Bypass auto save when only buffer open is one of these file types
  close_unsupported_windows = true, -- Close windows that aren't backed by normal file before autosaving a session
  args_allow_single_directory = true, -- Allow single directory arguments by default
  args_allow_files_auto_save = false, -- Don't save session for file args by default

  cwd_change_handling = false, -- Try to save/restore sessions when changing directories. pre/post cmds converted to hooks

  session_lens = {
    load_on_setup = true, -- Initialize on startup (requires Telescope)
    theme_conf = {}, -- Pass through for Telescope theme options
    previewer = false, -- File preview for session picker
  },
  session_control = {
    control_dir = vim.fn.stdpath "data" .. "/auto_session/", -- Auto session control dir, for control files, like alternating between two sessions with session-lens
    control_filename = "session_control.json", -- File name of the session control file
  },
  continue_restore_on_error = true, -- Suppress extraneous messages and source the whole session, even if there's an error. Set to false to get the line number of a restore error
}

I would plan to make the Lua config the default in the docs but I'd support the existing vimscript args. I think I'd add a config.lua file and do everything there but that's still just a thought.

@rmagatti What do you think? Are there other changes you'd make?

@cameronr cameronr added the enhancement New feature or request label Aug 5, 2024
@rmagatti
Copy link
Owner

rmagatti commented Aug 7, 2024

Hey @cameronr sorry, been a bit busy with work lately. Yes, I've been wanting to streamline the configs for sometime now. Something that particularly bothers me is that the LSP gets confused as to what options are available to use. And yes the vimscript configs need to be supported as legacy but certainly shouldn't be the default checks. Maybe a more streamlined implementation in a config.lua file like you mentioned could transparently handle whether the configs come from vimscript or the lua config.

I think the goal on a revamp like this should be to make the configs easily discoverable by the LSP, with proper docstring documentation for each field.

@cameronr
Copy link
Collaborator Author

No worries, this is just a background idea. Good point to make sure whatever we do works well with the lua ls. I'm still ruminating on this one. I'd like to do it at some point but may take some time.

@cameronr
Copy link
Collaborator Author

@rmagatti it's not done yet (still have to do readme, maybe unify autocmds), but i made a bunch of progress on the config cleanup. can see some of it here if you want to take an early look:

https://github.com/cameronr/auto-session/blob/config-overhaul/lua/auto-session/config.lua

it's working nicely with lua_ls (when using a config function, sadly lazy opts tables don't get the same treatment):

Screenshot 2024-08-22 at 15 08 47

@rmagatti
Copy link
Owner

Nice, that looks awesome!

@cameronr
Copy link
Collaborator Author

ooh, i figured out how to enable it for opts as well:

Screenshot 2024-08-25 at 20 30 03

@cameronr
Copy link
Collaborator Author

Closed in #359

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

2 participants