1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-26 20:21:03 +01:00

plugins/barbar: add nullOr workaround for keymaps lua warning

Currently, `types.either` has support for the new valueMeta attribute
added by v2 check and merge, while `types.nullOr` does not.

The `lua` option deprecation warning implemented in
`modules/keymaps.nix` requires `valueMeta`, so re-implement `nullOr`
using `types.either` as a workaround.
This commit is contained in:
Matt Sturgeon 2025-11-21 09:01:15 +00:00
parent d0b0b75a13
commit a635b56894
3 changed files with 28 additions and 12 deletions

View file

@ -5,7 +5,6 @@ let
defaultNullOpts
keymaps
mkNullOrOption
mkNullOrOption'
mkNullOrStr
;
keymapsActions = {
@ -45,6 +44,22 @@ let
orderByLanguage = "OrderByLanguage";
orderByWindowNumber = "OrderByWindowNumber";
};
# As of 2025-11-21, `either` supports `valueMeta`, while `nullOr` does not.
# The `lua` deprecation warning in `modules/keymaps.nix` requires `valueMeta`,
# so re-implement `nullOr` using `types.either` as a workaround.
#
# TODO: Remove with the warning, or once `nullOr` supports v2 check and merge.
v2NullOr =
type:
let
v1 = lib.types.nullOr type;
v2 = lib.types.either (lib.types.enum [ null ]) type;
in
v2
// {
inherit (v1) description descriptionClass getSubOptions;
};
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "barbar";
@ -56,14 +71,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraOptions = {
keymaps = mapAttrs (
optionName: funcName:
mkNullOrOption' {
type = keymaps.mkMapOptionSubmodule {
defaults = {
mode = "n";
action = "<Cmd>Buffer${funcName}<CR>";
};
lua = true;
};
lib.mkOption {
type = v2NullOr (
keymaps.mkMapOptionSubmodule {
defaults = {
mode = "n";
action = "<Cmd>Buffer${funcName}<CR>";
};
lua = true;
}
);
default = null;
apply = v: if v == null then null else keymaps.removeDeprecatedMapAttrs v;
description = "Keymap for function Buffer${funcName}";
}