treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -5,93 +5,91 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.auto-session;
in {
options.plugins.auto-session =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "auto-session";
in
{
options.plugins.auto-session = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "auto-session";
package = helpers.mkPackageOption "auto-session" pkgs.vimPlugins.auto-session;
package = helpers.mkPackageOption "auto-session" pkgs.vimPlugins.auto-session;
logLevel =
helpers.defaultNullOpts.mkEnum
["debug" "info" "warn" "error"]
"error"
"Sets the log level of the plugin.";
logLevel = helpers.defaultNullOpts.mkEnum [
"debug"
"info"
"warn"
"error"
] "error" "Sets the log level of the plugin.";
autoSession = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enables/disables auto creating, saving and restoring.
'';
autoSession = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enables/disables auto creating, saving and restoring.
'';
enableLastSession = helpers.defaultNullOpts.mkBool false ''
Whether to enable the "last session" feature.
'';
enableLastSession = helpers.defaultNullOpts.mkBool false ''
Whether to enable the "last session" feature.
'';
rootDir =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
rootDir =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
"{__raw = \"vim.fn.stdpath 'data' .. '/sessions/'\";}"
''
Root directory for session files.
Can be either a string or lua code (using `{__raw = 'foo';}`).
'';
createEnabled = helpers.mkNullOrOption types.bool ''
Whether to enable auto creating new sessions
'';
createEnabled = helpers.mkNullOrOption types.bool ''
Whether to enable auto creating new sessions
'';
suppressDirs = helpers.mkNullOrOption (with types; listOf str) ''
Suppress session create/restore if in one of the list of dirs.
'';
suppressDirs = helpers.mkNullOrOption (with types; listOf str) ''
Suppress session create/restore if in one of the list of dirs.
'';
allowedDirs = helpers.mkNullOrOption (with types; listOf str) ''
Allow session create/restore if in one of the list of dirs.
'';
allowedDirs = helpers.mkNullOrOption (with types; listOf str) ''
Allow session create/restore if in one of the list of dirs.
'';
useGitBranch = helpers.mkNullOrOption types.bool ''
Include git branch name in session name to differentiate between sessions for different
git branches.
'';
};
useGitBranch = helpers.mkNullOrOption types.bool ''
Include git branch name in session name to differentiate between sessions for different
git branches.
'';
};
autoSave = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto saving session.
'';
};
autoSave = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto saving session.
'';
};
autoRestore = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto restoring session.
'';
};
autoRestore = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto restoring session.
'';
};
cwdChangeHandling =
helpers.defaultNullOpts.mkNullable
cwdChangeHandling =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(enum [false])
(submodule {
options = {
restoreUpcomingSession = helpers.defaultNullOpts.mkBool true ''
Restore session for upcoming cwd on cwd change.
'';
either (enum [ false ]) (submodule {
options = {
restoreUpcomingSession = helpers.defaultNullOpts.mkBool true ''
Restore session for upcoming cwd on cwd change.
'';
preCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChangedPre` autocmd.
'';
preCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChangedPre` autocmd.
'';
postCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChanged` autocmd.
'';
};
})
postCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChanged` autocmd.
'';
};
})
)
"false"
''
@ -99,52 +97,49 @@ in {
Set to `false` to disable the feature.
'';
bypassSessionSaveFileTypes = helpers.mkNullOrOption (with types; listOf str) ''
List of file types to bypass auto save when the only buffer open is one of the file types
listed.
bypassSessionSaveFileTypes = helpers.mkNullOrOption (with types; listOf str) ''
List of file types to bypass auto save when the only buffer open is one of the file types
listed.
'';
sessionLens = {
loadOnSetup = helpers.defaultNullOpts.mkBool true ''
If `loadOnSetup` is set to false, one needs to eventually call
`require("auto-session").setup_session_lens()` if they want to use session-lens.
'';
sessionLens = {
loadOnSetup = helpers.defaultNullOpts.mkBool true ''
If `loadOnSetup` is set to false, one needs to eventually call
`require("auto-session").setup_session_lens()` if they want to use session-lens.
'';
themeConf =
helpers.defaultNullOpts.mkNullable
types.attrs
"{winblend = 10; border = true;}"
themeConf =
helpers.defaultNullOpts.mkNullable types.attrs "{winblend = 10; border = true;}"
"Theme configuration.";
previewer = helpers.defaultNullOpts.mkBool false ''
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.
'';
previewer = helpers.defaultNullOpts.mkBool false ''
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.
'';
sessionControl = {
controlDir =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
sessionControl = {
controlDir =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
"\"vim.fn.stdpath 'data' .. '/auto_session/'\""
''
Auto session control dir, for control files, like alternating between two sessions
with session-lens.
'';
controlFilename = helpers.defaultNullOpts.mkStr "session_control.json" ''
File name of the session control file.
'';
};
controlFilename = helpers.defaultNullOpts.mkStr "session_control.json" ''
File name of the session control file.
'';
};
};
};
config = let
setupOptions =
{
config =
let
setupOptions = {
log_level = cfg.logLevel;
auto_session_enable_last_session = cfg.autoSession.enableLastSession;
auto_session_root_dir = cfg.autoSession.rootDir;
@ -156,14 +151,15 @@ in {
auto_session_allowed_dirs = cfg.autoSession.allowedDirs;
auto_session_use_git_branch = cfg.autoSession.useGitBranch;
cwd_change_handling =
if isAttrs cfg.cwdChangeHandling
then
with cfg.cwdChangeHandling; {
if isAttrs cfg.cwdChangeHandling then
with cfg.cwdChangeHandling;
{
restore_upcoming_session = restoreUpcomingSession;
pre_cwd_changed_hook = preCwdChangedHook;
post_cwd_changed_hook = postCwdChangedHook;
}
else cfg.cwdChangeHandling;
else
cfg.cwdChangeHandling;
bypass_session_save_file_types = cfg.bypassSessionSaveFileTypes;
session_lens = with cfg.sessionLens; {
load_on_setup = loadOnSetup;
@ -174,11 +170,10 @@ in {
control_filename = controlFilename;
};
};
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('auto-session').setup(${helpers.toLuaObject setupOptions})