Open dhruvmanila opened 3 years ago
Cool, thanks for the report! I think you might be the first person I've encountered actually using the extensible handlers feature.
This is expected with #331, because I did not expect people to use handlers like this - I had in mind that a handler would do something at install/update time, and that anything that needed to be done at startup time would be in a setup
/config
key.
After #402, your use case will work again. Until then, we could hack in a shim to run handlers before fully managing plugins (see https://github.com/wbthomason/packer.nvim/commit/8596be799f4068f30721f982195ce5703fd912f0#diff-bae1764133e447f91f3c4ad4892840c0862259c0a2cdfde9b84dc264e72547edR255-R261), or you could perhaps work around this with a setup
function generator (though this is, I admit, a clunky workaround). What do you think?
This is expected with #331, because I did not expect people to use handlers like this - I had in mind that a handler would do something at install/update time, and that anything that needed to be done at startup time would be in a
setup
/config
key.
Ah, right that makes sense although my use case is somewhat different. I was looking for plugin information specifically URL, full repository name and installed location and most of that was not present in packer_plugins
global variable, but then I found this feature in the docs and so I thought to use it like this :)
After #402, your use case will work again. Until then, we could hack in a shim to run handlers before fully managing plugins (see 8596be7#diff-bae1764133e447f91f3c4ad4892840c0862259c0a2cdfde9b84dc264e72547edR255-R261), or you could perhaps work around this with a
setup
function generator (though this is, I admit, a clunky workaround). What do you think?
I don't understand how would we run handlers before managing plugins as the handler requires the information you're storing for each plugin in the manage
function such as type
, install_path
, short_name
, etc.
I do see that the manage_all_plugins
function is exposed through a private variable __manage_all
and calling that at the end of plugins.lua
file fixes the problem although I anticipate this should not be used.
nvim --version
:git --version
: 2.32.0Operating system/version: macOS Big Sur 11.3
Terminal name/version: Kitty 0.21.0
Steps to reproduce
Here's the gist of what's happening in my config:
In
init.lua
:In
core/plugins.lua
:Actual behaviour
Before this commit (8596be799f4068f30721f982195ce5703fd912f0), the handler would be called every time I open Neovim and thus can be used by Telescope right away. After that commit, the handler is not being called. Although, if I run any of the
Packer...
commands, the handler is being called.Expected behaviour
The handler should be called even on
packer.startup
packer files
Plugin specification file(s)
Post or link your plugin specification files here, if you aren't able to provide a minimal reproducer Link: https://github.com/dhruvmanila/dotfiles/blob/master/config/nvim/lua/core/plugins.luapacker log file
Post the contents of ~/.cache/nvim/packer.nvim.log here Here are the logs where I tried fixing the plugin at commit df0f740b97c0f1baeb08daa659a221b8eb2f5d6b and then at 8596be799f4068f30721f982195ce5703fd912f0. ``` [INFO Mon Jun 14 18:48:18 2021] .../site/pack/packer/start/packer.nvim/lua/packer/clean.lua:79: Already clean! [DEBUG Mon Jun 14 18:48:20 2021] ...site/pack/packer/start/packer.nvim/lua/packer/update.lua:80: Updated hrsh7th/nvim-compe: { err = {}, messages = { "79c9af4 Fix #395 (51 minutes ago)" }, output = { "remote: Enumerating objects: 131, done. \nremote: Counting objects: 1% (1/93) \rremote: Counting objects: 2% (2/93) \rremote: Counting objects: 3% (3/93) \rremote: Counting objects: 4% (4/93) \rremote: Counting objects: 5% (5/93) \rremote: Counting objects: 6% (6/93) \rremote: Counting objects: 7% (7/93) \rremote: Counting objects: 8% (8/93) \rremote: Counting objects: 9% (9/93) \rremote: Counting objects: 10% (10/93) \rremote: Counting objects: 11% (11/93) \rremote: Counting objects: 12% (12/93) \rremote: Counting objects: 13% (13/93) \rremote: Counting objects: 15% (14/93) \rremote: Counting objects: 16% (15/93) \rremote: Counting objects: 17% (16/93) \rremote: Counting objects: 18% (17/93) \rremote: Counting objects: 19% (18/93) \rremote: Counting objects: 20% (19/93) \rremote: Counting objects: 21% (20/93) \rremote: Counting objects: 22% (21/93) \rremote: Counting objects: 23% (22/93) \rremote: Counting objects: 24% (23/93) \rremote: Counting objects: 25% (24/93) \rremote: Counting objects: 26% (25/93) \rremote: Counting objects: 27% (26/93) \rremote: Counting objects: 29% (27/93) \rremote: Counting objects: 30% (28/93) \rremote: Counting objects: 31% (29/93) \rremote: Counting objects: 32% (30/93) \rremote: Counting objects: 33% (31/93) \rremote: Counting objects: 34% (32/93) \rremote: Counting objects: 35% (33/93) \rremote: Counting objects: 36% (34/93) \rremote: Counting objects: 37% (35/93) \rremote: Counting objects: 38% (36/93) \rremote: Counting objects: 39% (37/93) \rremote: Counting objects: 40% (38/93) \rremote: Counting objects: 41% (39/93) \rremote: Counting objects: 43% (40/93) \rremote: Counting objects: 44% (41/93) \rremote: Counting objects: 45% (42/93) \rremote: Counting objects: 46% (43/93) \rremote: Counting objects: 47% (44/93) \rremote: Counting objects: 48% (45/93) \rremote: Counting objects: 49% (46/93) \rremote: Counting objects: 50% (47/93) \rremote: Counting objects: 51% (48/93) \rremote: Counting objects: 52% (49/93) \rremote: Counting objects: 53% (50/93) \rremote: Counting objects: 54% (51/93) \rremote: Counting objects: 55% (52/93) \rremote: Counting objects: 56% (53/93) \rremote: Counting objects: 58% (54/93) \rremote: Counting objects: 59% (55/93) \rremote: Counting objects: 60% (56/93) \rremote: Counting objects: 61% (57/93) \rremote: Counting objects: 62% (58/93) \rremote: Counting objects: 63% (59/93) \rremote: Counting objects: 64% (60/93) \rremote: Counting objects: 65% (61/93) \rremote: Counting objects: 66% (62/93) \rremote: Counting objects: 67% (63/93) \rremote: Counting objects: 68% (64/93) \rremote: Counting objects: 69% (65/93) \rremote: Counting objects: 70% (66/93) \rremote: Counting objects: 72% (67/93) \rremote: Counting objects: 73% (68/93) \rremote: Counting objects: 74% (69/93) \rremote: Counting objects: 75% (70/93) \rremote: Counting objects: 76% (71/93) \rremote: Counting objects: 77% (72/93) \rremote: Counting objects: 78% (73/93) \rremote: Counting objects: 79% (74/93) \rremote: Counting objects: 80% (75/93) \rremote: Counting objects: 81% (76/93) \rremote: Counting objects: 82% (77/93) \rremote: Counting objects: 83% (78/93) \rremote: Counting objects: 84% (79/93) \rremote: Counting objects: 86% (80/93) \rremote: Counting objects: 87% (81/93) \rremote: Counting objects: 88% (82/93) \rremote: Counting objects: 89% (83/93) \rremote: Counting objects: 90% (84/93) \rremote: Counting objects: 91% (85/93) \rremote: Counting objects: 92% (86/93) \rremote: Counting objects: 93% (87/93) \rremote: Counting objects: 94% (88/93) \rremote: Counting objects: 95% (89/93) \rremote: Counting objects: 96% (90/93) \rremote: Counting objects: 97% (91/93) \rremote: Counting objects: 98% (92/93) \rremote: Counting objects: 100% (93/93) \rremote: Counting objects: 100% (93/93), done. \nremote: Compressing objects: 33% (1/3) \rremote: Compressing objects: 66% (2/3) \rremote: Compressing objects: 100% (3/3) \rremote: Compressing objects: 100% (3/3), done. \nremote: Total 14 (delta 10), reused 14 (delta 10), pack-reused 0 \nFrom https://github.com/hrsh7th/nvim-compe\n 96fafb5..79c9af4 master -> origin/master", "Updating 96fafb5..79c9af4\nFast-forward\n autoload/compe.vim | 12 +++++++-----\n autoload/vital/_compe/VS/Vim/Buffer.vim | 3 +--\n autoload/vital/_compe/VS/Vim/Window.vim | 11 +++++++++++\n lua/compe/completion.lua | 15 +++++++++------\n lua/compe/init.lua | 4 ++--\n 5 files changed, 30 insertions(+), 15 deletions(-)" }, revs = { "96fafb5", "79c9af4" } } [DEBUG Mon Jun 14 18:48:20 2021] ...site/pack/packer/start/packer.nvim/lua/packer/update.lua:80: Updated wbthomason/packer.nvim: { err = {}, messages = { "4012bd4 fix(README.md): refer to the correct noautocmd PR (#404) (18 hours ago)", "f9b484f compile.lua: better error messages when nil (#329) (22 hours ago)\n8596be7 Refactor: decrease cost of requiring main module (#331) (2 days ago)" }, output = { "Note: switching to 'df0f740b97c0f1baeb08daa659a221b8eb2f5d6b'.\n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by switching back to a branch.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -c with the switch command. Example:\n\n git switch -cpacker compiled file
Post the contents of `packer_compiled.vim` here ```vim " Automatically generated packer.nvim plugin loader code if !has('nvim-0.5') echohl WarningMsg echom "Invalid Neovim version for packer.nvim!" echohl None finish endif packadd packer.nvim try lua << END local time local profile_info local should_profile = true if should_profile then local hrtime = vim.loop.hrtime profile_info = {} time = function(chunk, start) if start then profile_info[chunk] = hrtime() else profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 end end else time = function(chunk, start) end end local function save_profiles(threshold) local sorted_times = {} for chunk_name, time_taken in pairs(profile_info) do sorted_times[#sorted_times + 1] = {chunk_name, time_taken} end table.sort(sorted_times, function(a, b) return a[2] > b[2] end) local results = {} for i, elem in ipairs(sorted_times) do if not threshold or threshold and elem[2] > threshold then results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' end end _G._packer = _G._packer or {} _G._packer.profile_output = results end time([[Luarocks path setup]], true) local package_path_str = "/Users/dhruvmanilawala/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/dhruvmanilawala/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/dhruvmanilawala/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/dhruvmanilawala/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" local install_cpath_pattern = "/Users/dhruvmanilawala/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" if not string.find(package.path, package_path_str, 1, true) then package.path = package.path .. ';' .. package_path_str end if not string.find(package.cpath, install_cpath_pattern, 1, true) then package.cpath = package.cpath .. ';' .. install_cpath_pattern end time([[Luarocks path setup]], false) time([[try_loadstring definition]], true) local function try_loadstring(s, component, name) local success, result = pcall(loadstring(s)) if not success then vim.schedule(function() vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) end) end return result end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { ["FixCursorHold.nvim"] = { loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim" }, ["applescript.vim"] = { loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/applescript.vim" }, ["clever-f.vim"] = { loaded = false, needs_bufread = false, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/opt/clever-f.vim" }, ["editorconfig-vim"] = { loaded = false, needs_bufread = false, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/opt/editorconfig-vim" }, ["gitsigns.nvim"] = { config = { "require('plugin.gitsigns')" }, loaded = false, needs_bufread = false, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/opt/gitsigns.nvim" }, ["gruvbox-material"] = { config = { "require('plugin.colorscheme')" }, loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/gruvbox-material" }, ["lir.nvim"] = { config = { "require('plugin.lir')" }, loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/lir.nvim" }, ["lsp-status.nvim"] = { loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/lsp-status.nvim" }, ["lsp_signature.nvim"] = { loaded = false, needs_bufread = false, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/opt/lsp_signature.nvim" }, ["lua-dev.nvim"] = { loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/lua-dev.nvim" }, ["luv-vimdocs"] = { loaded = true, path = "/Users/dhruvmanilawala/.local/share/nvim/site/pack/packer/start/luv-vimdocs" }, ["nvim-colorizer.lua"] = { config = { "\27LJ\2\n¡\1\0\0\6\0\n\0\0146\0\0\0009\0\1\0009\0\2\0'\2\3\0'\3\4\0'\4\5\0005\5\6\0B\0\5\0016\0\a\0'\2\b\0B\0\2\0029\0\t\0B\0\1\1K\0\1\0\nsetup\14colorizer\frequire\1\0\1\fnoremap\2\29