mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	modules: add prefix to plugin builder
This commit is contained in:
		
					parent
					
						
							
								859b03dfde
							
						
					
				
			
			
				commit
				
					
						88cf62fbc8
					
				
			
		
					 2 changed files with 13 additions and 7 deletions
				
			
		|  | @ -9,18 +9,23 @@ | ||||||
|   inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; |   inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; | ||||||
| 
 | 
 | ||||||
|   # Get the names of all flake inputs that start with the given prefix. |   # Get the names of all flake inputs that start with the given prefix. | ||||||
|   fromInputs = inputs: prefix: |   fromInputs = { | ||||||
|  |     inputs, | ||||||
|  |     prefix, | ||||||
|  |   }: | ||||||
|     mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs); |     mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs); | ||||||
| 
 | 
 | ||||||
|   pluginsFromInputs = attrNames (fromInputs inputs "plugin-"); |  | ||||||
| 
 |  | ||||||
|   #  Get the names of all flake inputs that start with the given prefix. |   #  Get the names of all flake inputs that start with the given prefix. | ||||||
|  |   pluginInputNames = attrNames (fromInputs { | ||||||
|  |     inherit inputs; | ||||||
|  |     prefix = "plugin-"; | ||||||
|  |   }); | ||||||
| 
 | 
 | ||||||
|   # You can either use the name of the plugin or a package. |   # You can either use the name of the plugin or a package. | ||||||
|   pluginType = nullOr ( |   pluginType = nullOr ( | ||||||
|     either |     either | ||||||
|     package |     package | ||||||
|     (enum (pluginsFromInputs ++ ["nvim-treesitter" "flutter-tools-patched" "vim-repeat"])) |     (enum (pluginInputNames ++ ["nvim-treesitter" "flutter-tools-patched" "vim-repeat"])) | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
|   pluginsType = listOf pluginType; |   pluginsType = listOf pluginType; | ||||||
|  | @ -47,7 +52,7 @@ | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| in { | in { | ||||||
|   inherit extraPluginType; |   inherit extraPluginType fromInputs; | ||||||
| 
 | 
 | ||||||
|   pluginsOpt = { |   pluginsOpt = { | ||||||
|     description, |     description, | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ inputs: { | ||||||
|   inherit (pkgs.vimUtils) buildVimPlugin; |   inherit (pkgs.vimUtils) buildVimPlugin; | ||||||
|   inherit (pkgs.neovimUtils) makeNeovimConfig; |   inherit (pkgs.neovimUtils) makeNeovimConfig; | ||||||
|   inherit (lib.attrsets) recursiveUpdate; |   inherit (lib.attrsets) recursiveUpdate; | ||||||
|  |   inherit (lib.asserts) assertMsg; | ||||||
| 
 | 
 | ||||||
|   extendedLib = import ../lib/stdlib-extended.nix lib inputs; |   extendedLib = import ../lib/stdlib-extended.nix lib inputs; | ||||||
| 
 | 
 | ||||||
|  | @ -28,11 +29,11 @@ inputs: { | ||||||
|   extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; |   extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; | ||||||
| 
 | 
 | ||||||
|   buildPlug = {pname, ...} @ args: |   buildPlug = {pname, ...} @ args: | ||||||
|     assert lib.asserts.assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter."; |     assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter."; | ||||||
|       buildVimPlugin (args |       buildVimPlugin (args | ||||||
|         // { |         // { | ||||||
|           version = "master"; |           version = "master"; | ||||||
|           src = getAttr pname inputs; |           src = getAttr ("plugin-" + pname) inputs; | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|   buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); |   buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue