nix-community.nixvim/plugins/by-name/auto-session/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

182 lines
5.5 KiB
Nix
Raw Normal View History

2023-06-14 16:24:01 +02:00
{
lib,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
2023-06-14 16:24:01 +02:00
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "auto-session";
package = "auto-session";
maintainers = [ lib.maintainers.khaneliman ];
# TODO: added 204-10-05 remove after 24.11
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"logLevel"
[
"sessionLens"
"loadOnSetup"
]
[
"sessionLens"
"themeConf"
]
[
"sessionLens"
"previewer"
]
[
"sessionControl"
"controlDir"
]
[
"sessionControl"
"controlFilename"
]
];
# NOTE: rename the old settings to use the correct variables
imports =
let
basePluginPath = [
"plugins"
"auto-session"
];
settingsPath = basePluginPath ++ [ "settings" ];
nestedAutoSessionPluginPath = basePluginPath ++ [ "autoSession" ];
in
[
(lib.mkRenamedOptionModule (
basePluginPath
++ [
"autoSave"
"enabled"
]
) (settingsPath ++ [ "auto_save" ]))
(lib.mkRenamedOptionModule (
basePluginPath
++ [
"autoRestore"
"enabled"
]
) (settingsPath ++ [ "auto_restore" ]))
2024-12-06 11:33:22 +01:00
(lib.mkRenamedOptionModule (basePluginPath ++ [ "bypassSessionSaveFileTypes" ]) (
settingsPath ++ [ "bypass_save_filetypes" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "enableLastSession" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "auto_restore_last_session" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "rootDir" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "root_dir" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "enabled" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "enabled" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "createEnabled" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "auto_create" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "suppressDirs" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "suppressed_dirs" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "allowedDirs" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "allowed_dirs" ]
))
(lib.mkRenamedOptionModule (nestedAutoSessionPluginPath ++ [ "useGitBranch" ]) (
2024-12-06 11:33:22 +01:00
settingsPath ++ [ "use_git_branch" ]
))
2024-12-06 11:33:22 +01:00
(lib.mkRemovedOptionModule (basePluginPath ++ [ "cwdChangeHandling" ]) ''
Please switch to `cwd_change_handling` with just a boolean value.
'')
];
settingsOptions = {
enabled = defaultNullOpts.mkBool true ''
Enables/disables auto creating, saving and restoring.
'';
2024-05-05 19:39:35 +02:00
root_dir = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/sessions/'"; } ''
Root directory for session files.
Can be either a string or lua code (using `{__raw = 'foo';}`).
'';
2023-06-14 16:24:01 +02:00
auto_save = defaultNullOpts.mkBool true ''
Whether to enable auto saving session.
'';
2023-06-14 16:24:01 +02:00
auto_restore = defaultNullOpts.mkBool true ''
Whether to enable auto restoring session.
'';
2023-06-14 16:24:01 +02:00
auto_create = defaultNullOpts.mkBool true ''
Whether to enable auto creating new sessions
'';
2023-06-14 16:24:01 +02:00
suppressed_dirs = defaultNullOpts.mkListOf types.str null ''
Suppress session create/restore if in one of the list of dirs.
'';
2023-06-14 16:24:01 +02:00
allowed_dirs = defaultNullOpts.mkListOf types.str null ''
Allow session create/restore if in one of the list of dirs.
'';
2023-06-14 16:24:01 +02:00
auto_restore_last_session = defaultNullOpts.mkBool false ''
On startup, loads the last saved session if session for cwd does not exist.
'';
2023-06-14 16:24:01 +02:00
use_git_branch = defaultNullOpts.mkBool false ''
Include git branch name in session name to differentiate between sessions for different
git branches.
'';
2023-06-14 16:24:01 +02:00
bypass_save_filetypes = defaultNullOpts.mkListOf types.str null ''
2023-06-14 16:24:01 +02:00
List of file types to bypass auto save when the only buffer open is one of the file types
listed.
'';
cwd_change_handling = defaultNullOpts.mkBool false ''
Follow cwd changes, saving a session before change and restoring after.
'';
log_level = defaultNullOpts.mkEnum [
"debug"
"info"
"warn"
"error"
] "error" "Sets the log level of the plugin.";
session_lens = {
load_on_setup = defaultNullOpts.mkBool true ''
If `load_on_setup` is set to false, one needs to eventually call
2023-06-14 16:24:01 +02:00
`require("auto-session").setup_session_lens()` if they want to use session-lens.
'';
theme_conf = defaultNullOpts.mkAttrsOf types.anything {
winblend = 10;
border = true;
} "Theme configuration.";
2023-06-14 16:24:01 +02:00
previewer = defaultNullOpts.mkBool false ''
2023-06-14 16:24:01 +02:00
Use default previewer config by setting the value to `null` if some sets previewer to
true in the custom config.
Passing in the boolean value errors out in the telescope code with the picker trying to
index a boolean instead of a table.
This fixes it but also allows for someone to pass in a table with the actual preview
configs if they want to.
'';
session_control = {
control_dir = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/auto_session/'"; } ''
Auto session control dir, for control files, like alternating between two sessions
with session-lens.
'';
2023-06-14 16:24:01 +02:00
control_filename = defaultNullOpts.mkStr "session_control.json" ''
2023-06-14 16:24:01 +02:00
File name of the session control file.
'';
};
};
2024-05-05 19:39:35 +02:00
};
2023-06-14 16:24:01 +02:00
}