aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/pack/_lsp.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-11-13 15:45:56 +0200
committerEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-11-17 12:47:29 +0200
commitb151aa761f09487046e8a201409672bba0ff7ae2 (patch)
tree39154c6298612f6ff65dbdeef6e11b182a077618 /runtime/lua/vim/pack/_lsp.lua
parent60bfc741edd3e2a78d4c06e4ea7c1c5321f7c294 (diff)
downloadrneovim-b151aa761f09487046e8a201409672bba0ff7ae2.tar.gz
rneovim-b151aa761f09487046e8a201409672bba0ff7ae2.tar.bz2
rneovim-b151aa761f09487046e8a201409672bba0ff7ae2.zip
feat(pack)!: synchronize lockfile with installed plugins when reading it
Problem: Lockfile can become out of sync with what is actually installed on disk when user performs (somewhat reasonable) manual actions like: - Delete lockfile and expect it to regenerate. - Delete plugin directory without `vim.pack.del()`. - Manually edit lock data in a bad way. Solution: Synchronize lockfile data with installed plugins on every lockfile read. In particular: 1. Install immediately all missing plugins with valid lock data. This helps with "manually delete plugin directory" case by prompting user to figure out how to properly delete a plugin. 2. Repair lock data for properly installed plugins. This helps with "manually deleted lockfile", "manually edited lockfile in an unexpected way", "installation terminated due to timeout" cases. 3. Remove unrepairable corrupted lock data and their plugins. This includes bad lock data for missing plugins and any lock data for corrupted plugins (right now this only means that plugin path is not a directory, but can be built upon). Step 1 also improves usability in case there are lazy loaded plugins that are rarely loaded (like on `FileType` event, for example): - Previously starting with config+lockfile on a new machine only installs rare `vim.pack.add()` plugin after it is called (while an entry in lockfile would still be present). This could be problematic if there is no Internet connection, for example. - Now all plugins from the lockfile are installed before actually executing the first `vim.pack.add()` call in 'init.lua'. And later they are only loaded on a rare `vim.pack.add()` call. --- Synchronizing lockfile on its every read makes it work more robustly if other `vim.pack` functions are called without any `vim.pack.add()`. --- Performance for a regular startup (good lockfile, everything is installed) is not affected and usually even increased. The bottleneck in this area is figuring out which plugins need to be installed. Previously the check was done by `vim.uv.fs_stat()` for every plugin in `vim.pack.add()`. Now it is replaced with a single `vim.fs.dir()` traversal during lockfile sync while later using lockfile data to figure out if plugin needs to be installed. The single `vim.fs.dir` approach scales better than `vim.uv.fs_stat`, but might be less performant if there are many plugins that will be not loaded via `vim.pack.add()` during startup. Rough estimate of how long the same steps (read lockfile and normalize plugin array) take with a single `vim.pack.add()` filled with 43 plugins benchmarking: - Before commit: ~700 ms - After commit: ~550 ms
Diffstat (limited to 'runtime/lua/vim/pack/_lsp.lua')
0 files changed, 0 insertions, 0 deletions