mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-25 03:39:40 +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:
parent
d0b0b75a13
commit
a635b56894
3 changed files with 28 additions and 12 deletions
|
|
@ -69,7 +69,6 @@ in
|
||||||
options.plugins.tmux-navigator.keymaps.valueMeta.list
|
options.plugins.tmux-navigator.keymaps.valueMeta.list
|
||||||
|
|
||||||
# NOTE: barbar added `mapOptionSubmodule` support shortly _before_ branching off 24.05
|
# 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) (
|
(lib.mapAttrsToList (name: opt: opt.valueMeta) (
|
||||||
builtins.removeAttrs options.plugins.barbar.keymaps [ "silent" ]
|
builtins.removeAttrs options.plugins.barbar.keymaps [ "silent" ]
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ let
|
||||||
defaultNullOpts
|
defaultNullOpts
|
||||||
keymaps
|
keymaps
|
||||||
mkNullOrOption
|
mkNullOrOption
|
||||||
mkNullOrOption'
|
|
||||||
mkNullOrStr
|
mkNullOrStr
|
||||||
;
|
;
|
||||||
keymapsActions = {
|
keymapsActions = {
|
||||||
|
|
@ -45,6 +44,22 @@ let
|
||||||
orderByLanguage = "OrderByLanguage";
|
orderByLanguage = "OrderByLanguage";
|
||||||
orderByWindowNumber = "OrderByWindowNumber";
|
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
|
in
|
||||||
lib.nixvim.plugins.mkNeovimPlugin {
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
name = "barbar";
|
name = "barbar";
|
||||||
|
|
@ -56,14 +71,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
keymaps = mapAttrs (
|
keymaps = mapAttrs (
|
||||||
optionName: funcName:
|
optionName: funcName:
|
||||||
mkNullOrOption' {
|
lib.mkOption {
|
||||||
type = keymaps.mkMapOptionSubmodule {
|
type = v2NullOr (
|
||||||
defaults = {
|
keymaps.mkMapOptionSubmodule {
|
||||||
mode = "n";
|
defaults = {
|
||||||
action = "<Cmd>Buffer${funcName}<CR>";
|
mode = "n";
|
||||||
};
|
action = "<Cmd>Buffer${funcName}<CR>";
|
||||||
lua = true;
|
};
|
||||||
};
|
lua = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
default = null;
|
||||||
apply = v: if v == null then null else keymaps.removeDeprecatedMapAttrs v;
|
apply = v: if v == null then null else keymaps.removeDeprecatedMapAttrs v;
|
||||||
description = "Keymap for function Buffer${funcName}";
|
description = "Keymap for function Buffer${funcName}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,8 +141,7 @@
|
||||||
(expect "any" "- `keymapsOnEvents.InsertEnter.\"[definition 1-entry 1]\".lua' is defined in `test-module'")
|
(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.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'")
|
(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;
|
test.runNvim = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue