File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -369,9 +369,19 @@ function M.enable()
369
369
break
370
370
end
371
371
end
372
- -- TODO: add an autocmd on BufWritePost that checks if its in a /lua folder
373
- -- if thats the case, then reset the plugin path.
374
- -- This will make sure we can properly load new top-level lua modules
372
+
373
+ -- this will reset the top-mods in case someone adds a new
374
+ -- top-level lua module to a path already on the rtp
375
+ vim .api .nvim_create_autocmd (" BufWritePost" , {
376
+ group = vim .api .nvim_create_augroup (" cache_topmods_reset" , { clear = true }),
377
+ callback = function (event )
378
+ local bufname = event .match --- @type string
379
+ local idx = bufname :find (" /lua/" , 1 , true )
380
+ if idx then
381
+ M .reset (bufname :sub (1 , idx - 1 ))
382
+ end
383
+ end ,
384
+ })
375
385
end
376
386
377
387
--- Disables the cache:
@@ -391,6 +401,7 @@ function M.disable()
391
401
end
392
402
end
393
403
table.insert (package.loaders , 2 , vim ._load_package )
404
+ vim .api .nvim_del_augroup_by_name (" cache_topmods_reset" )
394
405
end
395
406
396
407
--- Return the top-level `/lua/*` modules for this path
You can’t perform that action at this time.
0 commit comments