mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-11-03 20:22:21 +00:00 
			
		
		
		
	utility/qmk: add defaults and asserts
Add default values and assertions for required options.
This commit is contained in:
		
					parent
					
						
							
								ea55488f04
							
						
					
				
			
			
				commit
				
					
						059c508842
					
				
			
		
					 2 changed files with 22 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -18,9 +18,19 @@ in {
 | 
			
		|||
      '';
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    assertions = [{
 | 
			
		||||
      assertion = !(cfg.setupOpts.variant == "zmk") && !(cfg.setupOpts.comment_preview.position == "inside");
 | 
			
		||||
      message = "comment_preview.position can only be set to inside when using the qmk layoyt";
 | 
			
		||||
    }];
 | 
			
		||||
    assertions = [
 | 
			
		||||
      {
 | 
			
		||||
        assertion = cfg.setupOpts.variant != "zmk" && cfg.setupOpts.comment_preview.position != "inside";
 | 
			
		||||
        message = "comment_preview.position can only be set to inside when using the qmk layoyt";
 | 
			
		||||
      }
 | 
			
		||||
      {
 | 
			
		||||
        assertion = cfg.setupOpts.name != null;
 | 
			
		||||
        message = "qmk-nvim requires 'vim.utility.qmk.setupOpts.name' to be set.";
 | 
			
		||||
      }
 | 
			
		||||
      {
 | 
			
		||||
        assertion = cfg.setupOpts.layout != null;
 | 
			
		||||
        message = "qmk-nvim requires 'vim.utility.qmk.setupOpts.layout' to be set.";
 | 
			
		||||
      }
 | 
			
		||||
    ];
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,6 @@
 | 
			
		|||
{ 
 | 
			
		||||
  lib, 
 | 
			
		||||
  ... 
 | 
			
		||||
}: let
 | 
			
		||||
{lib, ...}: let
 | 
			
		||||
  inherit (lib.options) mkOption mkEnableOption;
 | 
			
		||||
  inherit (lib.types) attrsOf enum lines str;  
 | 
			
		||||
  inherit (lib.types) attrsOf nullOr enum lines str;
 | 
			
		||||
  inherit (lib.nvim.types) mkPluginSetupOption;
 | 
			
		||||
in {
 | 
			
		||||
  options.vim.utility.qmk = {
 | 
			
		||||
| 
						 | 
				
			
			@ -11,18 +8,20 @@ in {
 | 
			
		|||
 | 
			
		||||
    setupOpts = mkPluginSetupOption "qmk.nvim" {
 | 
			
		||||
      name = mkOption {
 | 
			
		||||
        type = str;
 | 
			
		||||
        type = nullOr str;
 | 
			
		||||
        default = null;
 | 
			
		||||
        description = "The name of the layout";
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      layout = mkOption {
 | 
			
		||||
        type = lines;
 | 
			
		||||
        type = nullOr lines;
 | 
			
		||||
        default = null;
 | 
			
		||||
        description = ''
 | 
			
		||||
          The keyboard key layout 
 | 
			
		||||
          The keyboard key layout
 | 
			
		||||
          see <https://github.com/codethread/qmk.nvim?tab=readme-ov-file#Layout> for more details
 | 
			
		||||
        '';
 | 
			
		||||
      };
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      variant = mkOption {
 | 
			
		||||
        type = enum ["qmk" "zmk"];
 | 
			
		||||
        default = "qmk";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue