aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/pack.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-08-09 15:33:33 +0300
committerEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-08-09 17:36:15 +0300
commitb337c6e0fc0a5c0c2e8125babded24ffcd544796 (patch)
tree29558c17cc016816e0276057059c0c5b9dd34537 /runtime/lua/vim/pack.lua
parente3913c0fc22f76b116de8f0c6d7a40395755f1d2 (diff)
downloadrneovim-b337c6e0fc0a5c0c2e8125babded24ffcd544796.tar.gz
rneovim-b337c6e0fc0a5c0c2e8125babded24ffcd544796.tar.bz2
rneovim-b337c6e0fc0a5c0c2e8125babded24ffcd544796.zip
fix(pack): update `add()` to have default `load=false` during startup
Problem: the `load=true` in `vim.pack.add()` means that `:packadd` is executed even during startup. This leads to force source of 'plugin/', which breaks the intended loading order (`:h load-plugins`) and results into sourcing them twice. This also makes it ignore `--noplugin` argument. Using `:packadd!` during startup is more appropriate, while `:packadd` afterwards is still more favorable to actually force 'plugin/' source (as there is no pre-defined mechanism that will load them later). Solution: have `load=false` default during startup, `true` - afterwards.
Diffstat (limited to 'runtime/lua/vim/pack.lua')
-rw-r--r--runtime/lua/vim/pack.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua
index 200f08e311..8069b5d947 100644
--- a/runtime/lua/vim/pack.lua
+++ b/runtime/lua/vim/pack.lua
@@ -669,7 +669,9 @@ end
--- @class vim.pack.keyset.add
--- @inlinedoc
---- @field load? boolean Load `plugin/` files and `ftdetect/` scripts. If `false`, works like `:packadd!`. Default `true`.
+--- Load `plugin/` files and `ftdetect/` scripts. If `false`, works like `:packadd!`.
+--- Default `false` during startup and `true` afterwards.
+--- @field load? boolean
--- Add plugin to current session
---
@@ -693,7 +695,7 @@ end
--- @param opts? vim.pack.keyset.add
function M.add(specs, opts)
vim.validate('specs', specs, vim.islist, false, 'list')
- opts = vim.tbl_extend('force', { load = true }, opts or {})
+ opts = vim.tbl_extend('force', { load = vim.v.vim_did_enter == 1 }, opts or {})
vim.validate('opts', opts, 'table')
--- @type vim.pack.Plug[]