mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/auto-session: remove with lib and helpers
This commit is contained in:
parent
28485b0e57
commit
7f4cfa2728
1 changed files with 26 additions and 27 deletions
|
@ -1,17 +1,16 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
|
inherit (lib) types;
|
||||||
cfg = config.plugins.auto-session;
|
cfg = config.plugins.auto-session;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.auto-session = helpers.neovim-plugin.extraOptionsOptions // {
|
options.plugins.auto-session = lib.nixvim.neovim-plugin.extraOptionsOptions // {
|
||||||
enable = mkEnableOption "auto-session";
|
enable = lib.mkEnableOption "auto-session";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "auto-session" {
|
package = lib.mkPackageOption pkgs "auto-session" {
|
||||||
default = [
|
default = [
|
||||||
|
@ -20,7 +19,7 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
logLevel = helpers.defaultNullOpts.mkEnum [
|
logLevel = lib.nixvim.defaultNullOpts.mkEnum [
|
||||||
"debug"
|
"debug"
|
||||||
"info"
|
"info"
|
||||||
"warn"
|
"warn"
|
||||||
|
@ -28,65 +27,65 @@ in
|
||||||
] "error" "Sets the log level of the plugin.";
|
] "error" "Sets the log level of the plugin.";
|
||||||
|
|
||||||
autoSession = {
|
autoSession = {
|
||||||
enabled = helpers.defaultNullOpts.mkBool true ''
|
enabled = lib.nixvim.defaultNullOpts.mkBool true ''
|
||||||
Enables/disables auto creating, saving and restoring.
|
Enables/disables auto creating, saving and restoring.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
enableLastSession = helpers.defaultNullOpts.mkBool false ''
|
enableLastSession = lib.nixvim.defaultNullOpts.mkBool false ''
|
||||||
Whether to enable the "last session" feature.
|
Whether to enable the "last session" feature.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
rootDir = helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/sessions/'"; } ''
|
rootDir = lib.nixvim.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/sessions/'"; } ''
|
||||||
Root directory for session files.
|
Root directory for session files.
|
||||||
Can be either a string or lua code (using `{__raw = 'foo';}`).
|
Can be either a string or lua code (using `{__raw = 'foo';}`).
|
||||||
'';
|
'';
|
||||||
|
|
||||||
createEnabled = helpers.mkNullOrOption types.bool ''
|
createEnabled = lib.nixvim.mkNullOrOption types.bool ''
|
||||||
Whether to enable auto creating new sessions
|
Whether to enable auto creating new sessions
|
||||||
'';
|
'';
|
||||||
|
|
||||||
suppressDirs = helpers.mkNullOrOption (with types; listOf str) ''
|
suppressDirs = lib.nixvim.mkNullOrOption (with types; listOf str) ''
|
||||||
Suppress session create/restore if in one of the list of dirs.
|
Suppress session create/restore if in one of the list of dirs.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
allowedDirs = helpers.mkNullOrOption (with types; listOf str) ''
|
allowedDirs = lib.nixvim.mkNullOrOption (with types; listOf str) ''
|
||||||
Allow session create/restore if in one of the list of dirs.
|
Allow session create/restore if in one of the list of dirs.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
useGitBranch = helpers.mkNullOrOption types.bool ''
|
useGitBranch = lib.nixvim.mkNullOrOption types.bool ''
|
||||||
Include git branch name in session name to differentiate between sessions for different
|
Include git branch name in session name to differentiate between sessions for different
|
||||||
git branches.
|
git branches.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
autoSave = {
|
autoSave = {
|
||||||
enabled = helpers.defaultNullOpts.mkNullable types.bool null ''
|
enabled = lib.nixvim.defaultNullOpts.mkNullable types.bool null ''
|
||||||
Whether to enable auto saving session.
|
Whether to enable auto saving session.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
autoRestore = {
|
autoRestore = {
|
||||||
enabled = helpers.defaultNullOpts.mkNullable types.bool null ''
|
enabled = lib.nixvim.defaultNullOpts.mkNullable types.bool null ''
|
||||||
Whether to enable auto restoring session.
|
Whether to enable auto restoring session.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
cwdChangeHandling =
|
cwdChangeHandling =
|
||||||
helpers.defaultNullOpts.mkNullable
|
lib.nixvim.defaultNullOpts.mkNullable
|
||||||
(
|
(
|
||||||
with types;
|
with types;
|
||||||
either (enum [ false ]) (submodule {
|
either (enum [ false ]) (submodule {
|
||||||
options = {
|
options = {
|
||||||
restoreUpcomingSession = helpers.defaultNullOpts.mkBool true ''
|
restoreUpcomingSession = lib.nixvim.defaultNullOpts.mkBool true ''
|
||||||
Restore session for upcoming cwd on cwd change.
|
Restore session for upcoming cwd on cwd change.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
|
preCwdChangedHook = lib.nixvim.defaultNullOpts.mkLuaFn "nil" ''
|
||||||
lua function hook.
|
lua function hook.
|
||||||
This is called after auto_session code runs for the `DirChangedPre` autocmd.
|
This is called after auto_session code runs for the `DirChangedPre` autocmd.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
|
postCwdChangedHook = lib.nixvim.defaultNullOpts.mkLuaFn "nil" ''
|
||||||
lua function hook.
|
lua function hook.
|
||||||
This is called after auto_session code runs for the `DirChanged` autocmd.
|
This is called after auto_session code runs for the `DirChanged` autocmd.
|
||||||
'';
|
'';
|
||||||
|
@ -99,23 +98,23 @@ in
|
||||||
Set to `false` to disable the feature.
|
Set to `false` to disable the feature.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bypassSessionSaveFileTypes = helpers.mkNullOrOption (with types; listOf str) ''
|
bypassSessionSaveFileTypes = lib.nixvim.mkNullOrOption (with types; listOf str) ''
|
||||||
List of file types to bypass auto save when the only buffer open is one of the file types
|
List of file types to bypass auto save when the only buffer open is one of the file types
|
||||||
listed.
|
listed.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
sessionLens = {
|
sessionLens = {
|
||||||
loadOnSetup = helpers.defaultNullOpts.mkBool true ''
|
loadOnSetup = lib.nixvim.defaultNullOpts.mkBool true ''
|
||||||
If `loadOnSetup` is set to false, one needs to eventually call
|
If `loadOnSetup` is set to false, one needs to eventually call
|
||||||
`require("auto-session").setup_session_lens()` if they want to use session-lens.
|
`require("auto-session").setup_session_lens()` if they want to use session-lens.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
themeConf = helpers.defaultNullOpts.mkAttrsOf types.anything {
|
themeConf = lib.nixvim.defaultNullOpts.mkAttrsOf types.anything {
|
||||||
winblend = 10;
|
winblend = 10;
|
||||||
border = true;
|
border = true;
|
||||||
} "Theme configuration.";
|
} "Theme configuration.";
|
||||||
|
|
||||||
previewer = helpers.defaultNullOpts.mkBool false ''
|
previewer = lib.nixvim.defaultNullOpts.mkBool false ''
|
||||||
Use default previewer config by setting the value to `null` if some sets previewer to
|
Use default previewer config by setting the value to `null` if some sets previewer to
|
||||||
true in the custom config.
|
true in the custom config.
|
||||||
Passing in the boolean value errors out in the telescope code with the picker trying to
|
Passing in the boolean value errors out in the telescope code with the picker trying to
|
||||||
|
@ -126,13 +125,13 @@ in
|
||||||
|
|
||||||
sessionControl = {
|
sessionControl = {
|
||||||
controlDir =
|
controlDir =
|
||||||
helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/auto_session/'"; }
|
lib.nixvim.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/auto_session/'"; }
|
||||||
''
|
''
|
||||||
Auto session control dir, for control files, like alternating between two sessions
|
Auto session control dir, for control files, like alternating between two sessions
|
||||||
with session-lens.
|
with session-lens.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
controlFilename = helpers.defaultNullOpts.mkStr "session_control.json" ''
|
controlFilename = lib.nixvim.defaultNullOpts.mkStr "session_control.json" ''
|
||||||
File name of the session control file.
|
File name of the session control file.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -153,7 +152,7 @@ in
|
||||||
auto_session_allowed_dirs = cfg.autoSession.allowedDirs;
|
auto_session_allowed_dirs = cfg.autoSession.allowedDirs;
|
||||||
auto_session_use_git_branch = cfg.autoSession.useGitBranch;
|
auto_session_use_git_branch = cfg.autoSession.useGitBranch;
|
||||||
cwd_change_handling =
|
cwd_change_handling =
|
||||||
if isAttrs cfg.cwdChangeHandling then
|
if lib.isAttrs cfg.cwdChangeHandling then
|
||||||
with cfg.cwdChangeHandling;
|
with cfg.cwdChangeHandling;
|
||||||
{
|
{
|
||||||
restore_upcoming_session = restoreUpcomingSession;
|
restore_upcoming_session = restoreUpcomingSession;
|
||||||
|
@ -174,11 +173,11 @@ in
|
||||||
};
|
};
|
||||||
} // cfg.extraOptions;
|
} // cfg.extraOptions;
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
extraPlugins = [ cfg.package ];
|
extraPlugins = [ cfg.package ];
|
||||||
|
|
||||||
extraConfigLua = ''
|
extraConfigLua = ''
|
||||||
require('auto-session').setup(${helpers.toLuaObject setupOptions})
|
require('auto-session').setup(${lib.nixvim.toLuaObject setupOptions})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue