Compare commits

..

2 commits

Author SHA1 Message Date
raf
f954c69c77
Merge 2c9202a48b into cb7ff874e2 2024-09-16 14:18:12 +02:00
2c9202a48b
neovim/basic: add undofile options
`vim.undoFile.enable` and `vim.undoFile.path` can be used to manipulate whether undofile will be enabled, and the location if it is enabled.
2024-08-27 23:46:44 +03:00

View file

@ -3,12 +3,11 @@
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression literalMD;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.strings) optionalString;
inherit (lib.types) enum bool str int either;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum bool str int nullOr either;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.lua) toLuaObject mkLuaInline;
inherit (lib.nvim.types) luaInline;
cfg = config.vim;
@ -162,21 +161,31 @@ in {
};
undoFile = {
enable = mkEnableOption "undofile for Neovim";
enable = mkEnableOption ''
undofile for Neovim.
::: {.warning}
[{option}`vim.undoFile.path`](#opt-vim.undoFile.path) **must** be set to a valid
path for this option to have any effect.
:::
'';
path = mkOption {
type = either str luaInline;
default = mkLuaInline "vim.fn.stdpath('state') .. '/nvf/undo'";
defaultText = literalMD ''
```nix
mkLuaInline "vim.fn.stdpath('state') .. '/nvf/undo'"
```
type = nullOr (either str luaInline);
default = null;
example = "os.getenv('XDG_DATA_HOME') .. '/nvf/undo'";
description = ''
Path to the file in which undo history will be saved. Must
an absolute path in a world-writable directory such as
{file}`~/.local/share`.
::: {.tip}
You can use use variable substitution as you normally would in Neovim to
pick directories that conform with XDG spec. **nvf**, by, default creates
{file}`$XDG_DATA_HOME/nvf` - which you may choose to use for storing
state such as the undofile.
:::
'';
example = literalMD ''
```nix
mkLuaInline "os.getenv('XDG_DATA_HOME') .. '/nvf/undo'"
```
'';
description = "Path to the file in which undo history will be saved";
};
};
};
@ -293,5 +302,16 @@ in {
vim.o.ignorecase = false
''}
'';
assertions = [
{
assertion = cfg.undoFile.enable -> cfg.undoFile.path != null;
message = ''
`vim.undoFile.enable` is set to true, but `vim.undoFile.path` is not set
as a valid path. Please set `vim.undoFile.path` to a valid path, or disable
the undoFile feature.
'';
}
];
};
}