perf: make load ultra ultra fast (#14)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
		
							parent
							
								
									333bf73bcb
								
							
						
					
					
						commit
						e3c162aad3
					
				@ -3,7 +3,26 @@ local sidebar = require("avante.sidebar")
 | 
				
			|||||||
local config = require("avante.config")
 | 
					local config = require("avante.config")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function M.setup(opts)
 | 
					function M.setup(opts)
 | 
				
			||||||
  require("tiktoken_lib").load()
 | 
					  local ok, LazyConfig = pcall(require, "lazy.core.config")
 | 
				
			||||||
 | 
					  if ok then
 | 
				
			||||||
 | 
					    local name = "avante.nvim"
 | 
				
			||||||
 | 
					    if LazyConfig.plugins[name] and LazyConfig.plugins[name]._.loaded then
 | 
				
			||||||
 | 
					      vim.schedule(function()
 | 
				
			||||||
 | 
					        require("tiktoken_lib").load()
 | 
				
			||||||
 | 
					      end)
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      vim.api.nvim_create_autocmd("User", {
 | 
				
			||||||
 | 
					        pattern = "LazyLoad",
 | 
				
			||||||
 | 
					        callback = function(event)
 | 
				
			||||||
 | 
					          if event.data == name then
 | 
				
			||||||
 | 
					            require("tiktoken_lib").load()
 | 
				
			||||||
 | 
					            return true
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end,
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  config.update(opts)
 | 
					  config.update(opts)
 | 
				
			||||||
  sidebar.setup()
 | 
					  sidebar.setup()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user