neovim/basic: add undofile options (#367)
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run

`vim.undoFile.enable` and `vim.undoFile.path` can be used to manipulate whether undofile will be enabled, and the location if it is enabled.
This commit is contained in:
raf 2024-09-19 19:07:25 +00:00 committed by GitHub
parent cb7ff874e2
commit e40d7a2a56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,11 +3,13 @@
lib,
...
}: let
inherit (lib.options) mkOption literalExpression;
inherit (lib.options) mkOption mkEnableOption literalExpression literalMD;
inherit (lib.strings) optionalString;
inherit (lib.types) enum bool str int;
inherit (lib.types) enum bool str int either;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) luaInline;
cfg = config.vim;
in {
@ -158,9 +160,29 @@ in {
default = "sensitive";
description = "Set the case sensitivity of search";
};
undoFile = {
enable = mkEnableOption "undofile for persistent undo behaviour";
path = mkOption {
type = either str luaInline;
default = mkLuaInline "vim.fn.stdpath('state') .. '/undo'";
defaultText = literalMD ''
```nix
mkLuaInline "vim.fn.stdpath('state') .. '/undo'"
```
'';
example = literalMD ''
```nix
mkLuaInline "os.getenv('XDG_DATA_HOME') .. '/nvf/undo'"
```
'';
description = "Path to the directory in which undo history will be stored";
};
};
};
config.vim.luaConfigRC.basic = entryAfter ["globalsScript"] ''
config = {
vim.luaConfigRC.basic = entryAfter ["globalsScript"] ''
-- Settings that are set for everything
vim.o.encoding = "utf-8"
vim.o.hidden = true
@ -178,6 +200,11 @@ in {
vim.g.mapleader = ${toLuaObject cfg.leaderKey}
vim.g.maplocalleader = ${toLuaObject cfg.leaderKey}
${optionalString cfg.undoFile.enable ''
vim.o.undofile = true
vim.o.undodir = ${toLuaObject cfg.undoFile.path}
''}
${optionalString cfg.splitBelow ''
vim.o.splitbelow = true
''}
@ -266,4 +293,5 @@ in {
vim.o.ignorecase = false
''}
'';
};
}