2023-02-06 02:26:52 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2023-11-07 00:50:27 +00:00
|
|
|
}: let
|
2024-03-12 00:48:24 +00:00
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (lib.lists) optionals;
|
|
|
|
inherit (lib.strings) concatStringsSep;
|
|
|
|
inherit (lib.trivial) boolToString;
|
|
|
|
inherit (lib.nvim.binds) mkBinding;
|
|
|
|
inherit (lib.nvim.dag) entryAnywhere;
|
2023-11-07 00:50:27 +00:00
|
|
|
|
2023-02-06 02:26:52 +00:00
|
|
|
cfg = config.vim.session.nvim-session-manager;
|
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable {
|
2024-03-12 00:48:24 +00:00
|
|
|
vim = {
|
|
|
|
startPlugins =
|
|
|
|
[
|
|
|
|
"nvim-session-manager"
|
|
|
|
"plenary-nvim"
|
|
|
|
]
|
|
|
|
++ optionals (cfg.usePicker) ["dressing-nvim"];
|
2023-02-06 02:26:52 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
maps.normal = mkMerge [
|
|
|
|
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
|
|
|
|
(mkBinding cfg.mappings.deleteSession ":SessionManager delete_session<CR>" "Delete session")
|
|
|
|
(mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session<CR>" "Save current session")
|
|
|
|
(mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session<CR>" "Load last session")
|
|
|
|
# TODO: load_current_dir_session
|
|
|
|
];
|
2023-04-09 13:18:09 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
luaConfigRC.nvim-session-manager = entryAnywhere ''
|
|
|
|
local Path = require('plenary.path')
|
|
|
|
local sm = require('session_manager.config')
|
|
|
|
require('session_manager').setup({
|
|
|
|
sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'),
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
path_replacer = '${toString cfg.pathReplacer}',
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
colon_replacer = '${toString cfg.colonReplacer}',
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autoload_mode = sm.AutoloadMode.${toString cfg.autoloadMode},
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autosave_last_session = ${boolToString cfg.autoSave.lastSession},
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autosave_ignore_not_normal = ${boolToString cfg.autoSave.ignoreNotNormal},
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autosave_ignore_dirs = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreDirs)}},
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autosave_ignore_filetypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreFiletypes)}},
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autosave_ignore_buftypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreBufTypes)}},
|
2023-04-07 22:44:40 +00:00
|
|
|
|
2024-03-12 00:48:24 +00:00
|
|
|
autosave_only_in_session = ${boolToString cfg.autoSave.onlyInSession},
|
|
|
|
max_path_length = ${toString cfg.maxPathLength},
|
|
|
|
})
|
|
|
|
'';
|
|
|
|
};
|
2023-02-06 02:26:52 +00:00
|
|
|
};
|
|
|
|
}
|