Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/keymaps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ in
options.plugins.tmux-navigator.keymaps.valueMeta.list

# NOTE: barbar added `mapOptionSubmodule` support shortly _before_ branching off 24.05
# FIXME: types.nullOr doesn't propagate valueMeta as it doesn't implement v2 check+merge
(lib.mapAttrsToList (name: opt: opt.valueMeta) (
builtins.removeAttrs options.plugins.barbar.keymaps [ "silent" ]
))
Expand Down
36 changes: 27 additions & 9 deletions plugins/by-name/barbar/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ let
defaultNullOpts
keymaps
mkNullOrOption
mkNullOrOption'
mkNullOrStr
;
keymapsActions = {
Expand Down Expand Up @@ -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";
Expand All @@ -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}";
}
Expand Down
3 changes: 1 addition & 2 deletions tests/test-sources/modules/keymaps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@
(expect "any" "- `keymapsOnEvents.InsertEnter.\"[definition 1-entry 1]\".lua' is defined in `test-module'")
(expect "any" "- `plugins.lsp.keymaps.extra.\"[definition 1-entry 1]\".lua' is defined in `test-module'")
(expect "any" "- `plugins.tmux-navigator.keymaps.\"[definition 1-entry 1]\".lua' is defined in `test-module'")
# FIXME: nullOr breaks our warning
# (expect "any" "- `plugins.barbar.keymaps.first.lua' is defined in `test-module'")
(expect "any" "- `plugins.barbar.keymaps.first.lua' is defined in `test-module'")
];

test.runNvim = false;
Expand Down