mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/persistence: convert to mkNeovimPlugin and fix settings
Restrict no nonnegative numbers Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com> chore: include optionsRenamedToSettings in TODO Merge imports Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>
This commit is contained in:
parent
0ebc64a232
commit
8899663b59
2 changed files with 53 additions and 79 deletions
|
@ -1,79 +1,57 @@
|
||||||
{
|
{ lib, ... }:
|
||||||
lib,
|
let
|
||||||
helpers,
|
inherit (lib.nixvim) defaultNullOpts literalLua;
|
||||||
config,
|
in
|
||||||
pkgs,
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
...
|
name = "persistence";
|
||||||
}:
|
packPathName = "persistence.nvim";
|
||||||
with lib;
|
package = "persistence-nvim";
|
||||||
{
|
description = "A simple lua plugin for automated session management.";
|
||||||
options.plugins.persistence = lib.nixvim.plugins.neovim.extraOptionsOptions // {
|
|
||||||
enable = mkEnableOption "persistence.nvim";
|
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "persistence.nvim" {
|
maintainers = [ lib.maintainers.jolars ];
|
||||||
default = [
|
|
||||||
"vimPlugins"
|
# TODO: introduced 2025-01-08: remove after 25.05
|
||||||
"persistence-nvim"
|
optionsRenamedToSettings = [
|
||||||
|
"dir"
|
||||||
|
];
|
||||||
|
imports =
|
||||||
|
let
|
||||||
|
basePluginPath = [
|
||||||
|
"plugins"
|
||||||
|
"persistence"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
map
|
||||||
|
(
|
||||||
|
option:
|
||||||
|
lib.mkRemovedOptionModule (basePluginPath ++ [ option ]) ''
|
||||||
|
This option has been deprecated upstream. The plugin now provides
|
||||||
|
user events to hook into instead.
|
||||||
|
''
|
||||||
|
)
|
||||||
|
[
|
||||||
|
"options"
|
||||||
|
"preSave"
|
||||||
|
"saveEmpty"
|
||||||
];
|
];
|
||||||
};
|
|
||||||
|
|
||||||
dir = helpers.defaultNullOpts.mkStr {
|
settingsOptions = {
|
||||||
__raw = ''vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/")'';
|
branch = defaultNullOpts.mkBool true ''
|
||||||
} "directory where session files are saved";
|
Use git branch to save session.
|
||||||
|
'';
|
||||||
|
|
||||||
options =
|
dir = defaultNullOpts.mkStr (literalLua "vim.fn.expand(vim.fn.stdpath('state') .. '/sessions/')") ''
|
||||||
let
|
Directory where session files are saved.
|
||||||
# https://neovim.io/doc/user/options.html#'sessionoptions'
|
'';
|
||||||
sessionOpts = [
|
|
||||||
"blank"
|
|
||||||
"buffers"
|
|
||||||
"curdir"
|
|
||||||
"folds"
|
|
||||||
"globals"
|
|
||||||
"help"
|
|
||||||
"localoptions"
|
|
||||||
"options"
|
|
||||||
"skiprtp"
|
|
||||||
"resize"
|
|
||||||
"sesdir"
|
|
||||||
"tabpages"
|
|
||||||
"terminal"
|
|
||||||
"winpos"
|
|
||||||
"winsize"
|
|
||||||
];
|
|
||||||
in
|
|
||||||
helpers.defaultNullOpts.mkListOf (types.enum sessionOpts) [
|
|
||||||
"buffers"
|
|
||||||
"curdir"
|
|
||||||
"tabpages"
|
|
||||||
"winsize"
|
|
||||||
"skiprtp"
|
|
||||||
] "sessionoptions used for saving";
|
|
||||||
|
|
||||||
preSave = helpers.defaultNullOpts.mkLuaFn "nil" "a function to call before saving the session";
|
need = defaultNullOpts.mkUnsignedInt 1 ''
|
||||||
|
Minimum number of file buffers that need to be open to save. Set to
|
||||||
saveEmpty = helpers.defaultNullOpts.mkBool false ''
|
0 to always save.
|
||||||
don't save if there are no open file buffers
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
config =
|
settingsExample = {
|
||||||
let
|
need = 0;
|
||||||
cfg = config.plugins.persistence;
|
branch = false;
|
||||||
in
|
};
|
||||||
mkIf cfg.enable {
|
|
||||||
extraPlugins = [ cfg.package ];
|
|
||||||
|
|
||||||
extraConfigLua =
|
|
||||||
let
|
|
||||||
opts = {
|
|
||||||
inherit (cfg) dir options;
|
|
||||||
pre_save = cfg.preSave;
|
|
||||||
save_empty = cfg.saveEmpty;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
''
|
|
||||||
require('persistence').setup(${lib.nixvim.toLuaObject opts})
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,11 @@
|
||||||
plugins.persistence = {
|
plugins.persistence = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
dir.__raw = ''vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/")'';
|
settings = {
|
||||||
options = [
|
branch = true;
|
||||||
"buffers"
|
dir.__raw = ''vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/")'';
|
||||||
"curdir"
|
need = 1;
|
||||||
"tabpages"
|
};
|
||||||
"winsize"
|
|
||||||
];
|
|
||||||
preSave = null;
|
|
||||||
saveEmpty = false;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue