diff --git a/lib/option-warnings.nix b/lib/option-warnings.nix new file mode 100644 index 00000000..bedf8e3c --- /dev/null +++ b/lib/option-warnings.nix @@ -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}") + ]; + }; + }; +} diff --git a/modules/warnings.nix b/modules/warnings.nix new file mode 100644 index 00000000..52c5fc80 --- /dev/null +++ b/modules/warnings.nix @@ -0,0 +1,12 @@ +{ lib, ... }: +with lib; + +{ + options = { + warnings = mkOption { + type = types.listOf types.str; + visible = false; + default = []; + }; + }; +} diff --git a/plugins/bufferlines/bufferline.nix b/plugins/bufferlines/bufferline.nix index 730ba830..55347cc4 100644 --- a/plugins/bufferlines/bufferline.nix +++ b/plugins/bufferlines/bufferline.nix @@ -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."; diff --git a/wrappers/hm.nix b/wrappers/hm.nix index 82dd8245..8d860aea 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -22,5 +22,8 @@ in (mkIf (!cfg.wrapRc) { xdg.configFile."nvim/init.lua".text = cfg.initContent; }) + ({ + warnings = cfg.warnings; + }) ]); } diff --git a/wrappers/nixos.nix b/wrappers/nixos.nix index cfd1f905..326cd8e5 100644 --- a/wrappers/nixos.nix +++ b/wrappers/nixos.nix @@ -23,5 +23,8 @@ in environment.etc."nvim/sysinit.lua".text = cfg.initContent; environment.variables."VIM" = "/etc/nvim"; }) + ({ + warnings = cfg.warnings; + }) ]); }