session/nvim-session-manager: fix option descriptions; more explicit library inherits

This commit is contained in:
raf 2025-03-04 23:30:52 +03:00
parent d12846211b
commit 27978c7186
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF

View file

@ -1,7 +1,10 @@
{lib, ...}: let
inherit (lib.types) nullOr str bool;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.strings) isString;
inherit (lib.types) nullOr str bool int enum listOf either;
inherit (lib.generators) mkLuaInline;
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
inherit (lib.nvim.types) luaInline mkPluginSetupOption;
in {
imports = let
renameSetupOpt = oldPath: newPath:
@ -51,70 +54,100 @@ in {
usePicker = mkOption {
type = bool;
default = true;
description = "Whether or not we should use dressing.nvim to build a session picker UI";
description = ''
Whether we should use `dressing.nvim` to build a session picker UI
'';
};
setupOpts = {
setupOpts = mkPluginSetupOption "which-key" {
path_replacer = mkOption {
type = types.str;
type = str;
default = "__";
description = "The character to which the path separator will be replaced for session files";
description = ''
The character to which the path separator will be replaced for session files
'';
};
colon_replacer = mkOption {
type = types.str;
type = str;
default = "++";
description = "The character to which the colon symbol will be replaced for session files";
description = ''
The character to which the colon symbol will be replaced for session files
'';
};
autoload_mode = mkOption {
type = types.enum ["Disabled" "CurrentDir" "LastSession"];
# variable `sm` referenced from ./config.nix
apply = value: mkLuaInline "sm.AutoloadMode.${value}";
type = either (enum ["Disabled" "CurrentDir" "LastSession"]) luaInline;
# Variable 'sm' is defined in the pluginRC of nvim-session-manager. The
# definition is as follows: `local sm = require('session_manager.config')`
apply = val:
if isString val
then mkLuaInline "sm.AutoloadMode.${val}"
else val;
default = "LastSession";
description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession";
description = ''
Define what to do when Neovim is started without arguments.
Takes either one of `"Disabled"`, `"CurrentDir"`, `"LastSession` in which case the value
will be inserted into `sm.AutoloadMode.<value>`, or an inline Lua value.
'';
};
max_path_length = mkOption {
type = types.nullOr types.int;
type = nullOr int;
default = 80;
description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all";
description = ''
Shorten the display path if length exceeds this threshold.
Use `0` if don't want to shorten the path at all
'';
};
autosave_last_session = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Automatically save last session on exit and on session switch";
description = ''
Automatically save last session on exit and on session switch
'';
};
autosave_ignore_not_normal = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed";
description = ''
Plugin will not save a session when no buffers are opened, or all of them are
not writable or listed
'';
};
autosave_ignore_dirs = mkOption {
type = types.listOf types.str;
type = listOf str;
default = [];
description = "A list of directories where the session will not be autosaved";
};
autosave_ignore_filetypes = mkOption {
type = types.listOf types.str;
type = listOf str;
default = ["gitcommit"];
description = "All buffers of these file types will be closed before the session is saved";
description = ''
All buffers of these file types will be closed before the session is saved
'';
};
autosave_ignore_buftypes = mkOption {
type = types.listOf types.str;
type = listOf str;
default = [];
description = "All buffers of these buffer types will be closed before the session is saved";
description = ''
All buffers of these buffer types will be closed before the session is saved
'';
};
autosave_only_in_session = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Always autosaves session. If true, only autosaves after a session is active";
description = ''
Always autosaves session. If `true`, only autosaves after a session is active
'';
};
};
};