@@ -13,7 +13,8 @@ local plugin_map = {}
1313
1414-- Data paths
1515local data_dir = vim .fn .stdpath (' data' )
16- local PACK_DIR = joinpath (data_dir , ' strive.nvim' )
16+ local START_DIR = joinpath (data_dir , ' site' , ' pack' , ' strive' , ' start' )
17+ local OPT_DIR = joinpath (data_dir , ' site' , ' pack' , ' strive' , ' opt' )
1718
1819-- Add to packpath
1920vim .opt .packpath :prepend (joinpath (data_dir , ' site' ))
629630
630631-- Get the plugin installation path
631632function Plugin :get_path ()
632- return (not self .is_local and not self .local_path ) and joinpath (PACK_DIR , self .plugin_name )
633+ return (not self .is_local and not self .local_path )
634+ and joinpath (self .is_lazy and OPT_DIR or START_DIR , self .plugin_name )
633635 or (joinpath (self .local_path , self .plugin_name ) or self .name )
634636end
635637
@@ -708,15 +710,14 @@ function Plugin:load(do_action, callback)
708710 load_opts (self .init_opts )
709711 end
710712
711- vim .opt .rtp :append (plugin_path )
713+ if self .is_local then
714+ vim .opt .rtp :append (plugin_path )
712715
713- local after_path = joinpath (plugin_path , ' after' )
714- if isdir (after_path ) then
715- vim .opt .rtp :append (after_path )
716- end
716+ local after_path = joinpath (plugin_path , ' after' )
717+ if isdir (after_path ) then
718+ vim .opt .rtp :append (after_path )
719+ end
717720
718- local plugin_dir = joinpath (plugin_path , ' plugin' )
719- if isdir (plugin_dir ) then
720721 local result = Async .try_await (self :load_scripts ())
721722 if result .error then
722723 M .log (
@@ -725,6 +726,8 @@ function Plugin:load(do_action, callback)
725726 )
726727 return
727728 end
729+ elseif self .is_lazy then
730+ vim .cmd .packadd (self .plugin_name )
728731 end
729732
730733 self .loaded = true
@@ -894,17 +897,23 @@ function Plugin:cmd(commands)
894897 -- Remove this command to avoid recursion
895898 pcall (api .nvim_del_user_command , name )
896899 local args = opts .args ~= ' ' and (' ' .. opts .args ) or ' '
897- self :load (false , function ()
898- execute (name , opts .bang , args )
899- end )
900+ local bang = opts .bang
901+
902+ Async .async (function ()
903+ self :load ()
904+ if self .is_local then
905+ Async .await (Async .delay (5 ))
906+ end
907+ Async .safe_schedule (function ()
908+ execute (name , bang , args )
909+ end )
910+ end )()
900911 end , {
901912 nargs = ' *' ,
902913 bang = true ,
903914 complete = function (_ , cmd_line )
904915 if not self .loaded then
905916 self :load ()
906- -- wait async source for get completion of command
907- vim .wait (10 )
908917 end
909918 local ok , result = pcall (vim .fn .getcompletion , cmd_line , ' cmdline' )
910919 return ok and result or {}
@@ -1020,7 +1029,7 @@ function Plugin:theme(name)
10201029 local installed = Async .await (self :is_installed ())
10211030 if installed then
10221031 vim .schedule (function ()
1023- vim .opt .rtp :append (joinpath (PACK_DIR , self .plugin_name ))
1032+ vim .opt .rtp :append (joinpath (START_DIR , self .plugin_name ))
10241033 vim .cmd .colorscheme (self .colorscheme )
10251034 end )
10261035 end
@@ -1064,7 +1073,7 @@ function Plugin:depends(deps)
10641073 return self
10651074end
10661075
1067- -- MODIFIED: Install the plugin with branch support
1076+ -- Install the plugin
10681077function Plugin :install ()
10691078 if self .is_local or not self .is_remote then
10701079 return Async .wrap (function (cb )
@@ -1145,7 +1154,6 @@ function Plugin:install()
11451154 end )()
11461155end
11471156
1148- -- MODIFIED: Check for updates with branch awareness
11491157function Plugin :has_updates ()
11501158 return Async .wrap (function (callback )
11511159 if self .is_local or not self .is_remote then
@@ -1198,7 +1206,6 @@ function Plugin:has_updates()
11981206 end )()
11991207end
12001208
1201- -- MODIFIED: Update plugin with branch support
12021209function Plugin :update (skip_check )
12031210 if self .is_local or not self .is_remote then
12041211 return Async .wrap (function (cb )
@@ -1318,7 +1325,6 @@ function Plugin:update(skip_check)
13181325 end )()
13191326end
13201327
1321- -- MODIFIED: Install with retry and branch support
13221328function Plugin :install_with_retry ()
13231329 if self .is_local or not self .is_remote then
13241330 return Async .wrap (function (cb )
@@ -1401,7 +1407,6 @@ function Plugin:install_with_retry()
14011407 callback (result .success )
14021408 end )()
14031409end
1404-
14051410-- =====================================================================
14061411-- 6. Manager Functions
14071412-- =====================================================================
@@ -1622,7 +1627,8 @@ function M.clean()
16221627 end
16231628
16241629 -- Scan both start and opt directories
1625- scan_directory (PACK_DIR )
1630+ scan_directory (START_DIR )
1631+ scan_directory (OPT_DIR )
16261632
16271633 local strive_plugin = Plugin .new ({
16281634 name = ' nvimdev/strive' ,
0 commit comments