mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
5
modules/plugins/session/default.nix
Normal file
5
modules/plugins/session/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
imports = [
|
||||
./nvim-session-manager
|
||||
];
|
||||
}
|
35
modules/plugins/session/nvim-session-manager/config.nix
Normal file
35
modules/plugins/session/nvim-session-manager/config.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf optionals mkMerge mkBinding nvim;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.session.nvim-session-manager;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins =
|
||||
[
|
||||
"nvim-session-manager"
|
||||
"plenary-nvim"
|
||||
]
|
||||
++ optionals cfg.usePicker ["dressing-nvim"];
|
||||
|
||||
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
|
||||
];
|
||||
|
||||
luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
||||
local Path = require('plenary.path')
|
||||
local sm = require('session_manager.config')
|
||||
require('session_manager').setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/session/nvim-session-manager/default.nix
Normal file
6
modules/plugins/session/nvim-session-manager/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./nvim-session-manager.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.types) nullOr str bool;
|
||||
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
|
||||
in {
|
||||
imports = let
|
||||
renameSetupOpt = oldPath: newPath:
|
||||
mkRenamedOptionModule (["vim" "session" "nvim-session-manager"] ++ oldPath) (["vim" "session" "nvim-session-manager" "setupOpts"] ++ newPath);
|
||||
in [
|
||||
(renameSetupOpt ["pathReplacer"] ["path_replacer"])
|
||||
(renameSetupOpt ["colonReplacer"] ["colon_replacer"])
|
||||
(renameSetupOpt ["autoloadMode"] ["autoload_mode"])
|
||||
(renameSetupOpt ["maxPathLength"] ["max_path_length"])
|
||||
(renameSetupOpt ["autoSave" "lastSession"] ["autosave_last_session"])
|
||||
(renameSetupOpt ["autoSave" "ignoreNotNormal"] ["autosave_ignore_not_normal"])
|
||||
(renameSetupOpt ["autoSave" "ignoreDirs"] ["autosave_ignore_dirs"])
|
||||
(renameSetupOpt ["autoSave" "ignoreFiletypes"] ["autosave_ignore_filetypes"])
|
||||
(renameSetupOpt ["autoSave" "ignoreBufTypes"] ["autosave_ignore_buftypes"])
|
||||
(renameSetupOpt ["autoSave" "onlyInSession"] ["autosave_only_in_session"])
|
||||
];
|
||||
|
||||
options.vim.session.nvim-session-manager = {
|
||||
enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode";
|
||||
|
||||
mappings = {
|
||||
loadSession = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Load session";
|
||||
default = "<leader>sl";
|
||||
};
|
||||
|
||||
deleteSession = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Delete session";
|
||||
default = "<leader>sd";
|
||||
};
|
||||
|
||||
saveCurrentSession = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Save current session";
|
||||
default = "<leader>sc";
|
||||
};
|
||||
|
||||
loadLastSession = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Load last session";
|
||||
default = "<leader>slt";
|
||||
};
|
||||
};
|
||||
|
||||
usePicker = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Whether or not we should use dressing.nvim to build a session picker UI";
|
||||
};
|
||||
|
||||
setupOpts = {
|
||||
path_replacer = mkOption {
|
||||
type = types.str;
|
||||
default = "__";
|
||||
description = "The character to which the path separator will be replaced for session files";
|
||||
};
|
||||
|
||||
colon_replacer = mkOption {
|
||||
type = types.str;
|
||||
default = "++";
|
||||
description = "The character to which the colon symbol will be replaced for session files";
|
||||
};
|
||||
|
||||
autoload_mode = mkOption {
|
||||
type = types.enum ["Disabled" "CurrentDir" "LastSession"];
|
||||
default = "LastSession";
|
||||
description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession";
|
||||
};
|
||||
|
||||
max_path_length = mkOption {
|
||||
type = types.nullOr types.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";
|
||||
};
|
||||
|
||||
autosave_last_session = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Automatically save last session on exit and on session switch";
|
||||
};
|
||||
|
||||
autosave_ignore_not_normal = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed";
|
||||
};
|
||||
|
||||
autosave_ignore_dirs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "A list of directories where the session will not be autosaved";
|
||||
};
|
||||
|
||||
autosave_ignore_filetypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["gitcommit"];
|
||||
description = "All buffers of these file types will be closed before the session is saved";
|
||||
};
|
||||
|
||||
autosave_ignore_buftypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "All buffers of these bufer types will be closed before the session is saved";
|
||||
};
|
||||
|
||||
autosave_only_in_session = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Always autosaves session. If true, only autosaves after a session is active";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue