mirror of
				https://github.com/folke/lazy.nvim.git
				synced 2025-10-31 14:31:04 +00:00 
			
		
		
		
	feat(plugin): added support for virtual plugins. Closes #1836
This commit is contained in:
		
					parent
					
						
							
								3388a26417
							
						
					
				
			
			
				commit
				
					
						ee64abc76b
					
				
			
		
					 5 changed files with 14 additions and 5 deletions
				
			
		|  | @ -341,7 +341,9 @@ function M._load(plugin, reason, opts) | |||
|   Util.track({ plugin = plugin.name, start = reason.start }) | ||||
|   Handler.disable(plugin) | ||||
| 
 | ||||
|   M.add_to_rtp(plugin) | ||||
|   if not plugin.virtual then | ||||
|     M.add_to_rtp(plugin) | ||||
|   end | ||||
| 
 | ||||
|   if plugin._.pkg and plugin._.pkg.source == "rockspec" then | ||||
|     M.add_to_luapath(plugin) | ||||
|  | @ -353,7 +355,9 @@ function M._load(plugin, reason, opts) | |||
|     end, "Failed to load deps for " .. plugin.name) | ||||
|   end | ||||
| 
 | ||||
|   M.packadd(plugin.dir) | ||||
|   if not plugin.virtual then | ||||
|     M.packadd(plugin.dir) | ||||
|   end | ||||
|   if plugin.config or plugin.opts then | ||||
|     M.config(plugin) | ||||
|   end | ||||
|  |  | |||
|  | @ -213,6 +213,8 @@ function M:_rebuild(name) | |||
|   plugin.dir = super.dir | ||||
|   if plugin.dir then | ||||
|     plugin.dir = Util.norm(plugin.dir) | ||||
|   elseif super.virtual then | ||||
|     plugin.dir = Util.norm("/dev/null/" .. plugin.name) | ||||
|   else | ||||
|     if plugin.dev == nil and plugin.url then | ||||
|       for _, pattern in ipairs(Config.options.dev.patterns) do | ||||
|  |  | |||
|  | @ -237,12 +237,14 @@ function M.update_state() | |||
|         or plugin.cmd | ||||
|       plugin.lazy = lazy and true or false | ||||
|     end | ||||
|     if plugin.dir:find(Config.options.root, 1, true) == 1 then | ||||
|     if plugin.virtual then | ||||
|       plugin._.is_local = true | ||||
|       plugin._.installed = true -- local plugins are managed by the user | ||||
|     elseif plugin.dir:find(Config.options.root, 1, true) == 1 then | ||||
|       plugin._.installed = installed[plugin.name] ~= nil | ||||
|       installed[plugin.name] = nil | ||||
|     else | ||||
|       plugin._.is_local = true | ||||
|       plugin._.installed = true -- local plugins are managed by the user | ||||
|       plugin._.installed = vim.fn.isdirectory(plugin.dir) == 1 | ||||
|     end | ||||
|   end | ||||
|  |  | |||
|  | @ -270,7 +270,7 @@ function M.get_unloaded_rtp(modname, opts) | |||
|   local Config = require("lazy.core.config") | ||||
|   if Config.spec then | ||||
|     for _, plugin in pairs(Config.spec.plugins) do | ||||
|       if not (plugin._.loaded or plugin.module == false) then | ||||
|       if not (plugin._.loaded or plugin.module == false or plugin.virtual) then | ||||
|         if norm == M.normname(plugin.name) then | ||||
|           table.insert(rtp, 1, plugin.dir) | ||||
|         else | ||||
|  |  | |||
|  | @ -60,6 +60,7 @@ | |||
| ---@field priority? number Only useful for lazy=false plugins to force loading certain plugins first. Default priority is 50 | ||||
| ---@field dev? boolean If set, then link to the respective folder under your ~/projects | ||||
| ---@field rocks? string[] | ||||
| ---@field virtual? boolean virtual plugins won't be installed or added to the rtp. | ||||
| 
 | ||||
| ---@class LazyPlugin: LazyPluginBase,LazyPluginHandlers,LazyPluginHooks,LazyPluginRef | ||||
| ---@field dependencies? string[] | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue