mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-08 11:55:17 +02:00
added warnings module
This commit is contained in:
parent
e607ab67a5
commit
5a222885fc
5 changed files with 65 additions and 8 deletions
31
lib/option-warnings.nix
Normal file
31
lib/option-warnings.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ lib, ... }:
|
||||
with lib;
|
||||
|
||||
rec {
|
||||
mkDeprecatedOption =
|
||||
{ option # an array of the path to the option
|
||||
, alternative ? null
|
||||
, message ? null
|
||||
, visible ? false
|
||||
, ...
|
||||
}:
|
||||
{ options, ... }:
|
||||
let
|
||||
fromOpt = getAttrFromPath option options;
|
||||
fullMessage = "The option `${showOption option}` has been deprecated." +
|
||||
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") +
|
||||
(optionalString (message != null) " Message: ${message}");
|
||||
in
|
||||
{
|
||||
options = setAttrByPath option
|
||||
(mkOption {
|
||||
inherit visible;
|
||||
description = fullMessage;
|
||||
});
|
||||
config = mkIf (fromOpt.isDefined) {
|
||||
warnings = [
|
||||
("Nixvim: ${fullMessage}")
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
12
modules/warnings.nix
Normal file
12
modules/warnings.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ lib, ... }:
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
warnings = mkOption {
|
||||
type = types.listOf types.str;
|
||||
visible = false;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, pkgs, lib, ... }@args:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.bufferline;
|
||||
helpers = import ../helpers.nix { inherit lib; };
|
||||
optionWarnings = import ../../lib/option-warnings.nix args;
|
||||
helpers = import ../helpers.nix args;
|
||||
|
||||
highlight = mkOption {
|
||||
type = types.nullOr (types.submodule ({ ... }: {
|
||||
|
@ -23,6 +24,13 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(optionWarnings.mkDeprecatedOption {
|
||||
option = [ "plugins" "bufferline" "indicatorIcon" ];
|
||||
alternative = [ "plugins" "bufferline" "indicator" "icon" ];
|
||||
})
|
||||
];
|
||||
|
||||
options = {
|
||||
plugins.bufferline = {
|
||||
enable = mkEnableOption "Enable bufferline";
|
||||
|
@ -56,12 +64,12 @@ in
|
|||
description = "Command or function run when middle clicking on a buffer.";
|
||||
default = null;
|
||||
};
|
||||
indicatorIcon = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The Icon shown as a indicator for buffer. Changing it is NOT recommended,
|
||||
this is intended to be an escape hatch for people who cannot bear it for whatever reason.";
|
||||
default = null;
|
||||
};
|
||||
# indicatorIcon = mkOption {
|
||||
# type = types.nullOr types.str;
|
||||
# description = "The Icon shown as a indicator for buffer. Changing it is NOT recommended,
|
||||
# this is intended to be an escape hatch for people who cannot bear it for whatever reason.";
|
||||
# default = null;
|
||||
# };
|
||||
bufferCloseIcon = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The close icon for each buffer.";
|
||||
|
|
|
@ -22,5 +22,8 @@ in
|
|||
(mkIf (!cfg.wrapRc) {
|
||||
xdg.configFile."nvim/init.lua".text = cfg.initContent;
|
||||
})
|
||||
({
|
||||
warnings = cfg.warnings;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -23,5 +23,8 @@ in
|
|||
environment.etc."nvim/sysinit.lua".text = cfg.initContent;
|
||||
environment.variables."VIM" = "/etc/nvim";
|
||||
})
|
||||
({
|
||||
warnings = cfg.warnings;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue