-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with lazy loading via cmd
options
#316
Comments
init.lua for reference as well: require 'plugins'
vim.api.nvim_command [[ augroup auto_compile ]]
vim.api.nvim_command [[ autocmd! ]]
vim.api.nvim_command [[ autocmd BufWritePost plugins.lua PackerCompile ]]
vim.api.nvim_command [[ augroup END ]]
vim.cmd [[source $HOME/.config/nvim/vimscript/packer_compiled.vim]] |
@garymh Thanks for the report! I'm having trouble reproducing this - using your |
@wbthomason Thanks for reading it! 😄 🤔 Hmm. That's odd! It must be something screwy with my setup. Here's the compiled file: " 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 = false
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/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/gary/.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
print('Error running ' .. component .. ' for ' .. name)
error(result)
end
return result
end
time("try_loadstring definition", false)
time("Defining packer_plugins", true)
_G.packer_plugins = {
["packer.nvim"] = {
loaded = false,
needs_bufread = false,
path = "/Users/gary/.local/share/nvim/site/pack/packer/opt/packer.nvim"
},
["switch.vim"] = {
commands = { "Switch", "SwitchReverse" },
config = { "\27LJ\2\n§\2\0\0\3\0\n\0\0196\0\0\0009\0\1\0004\1\b\0005\2\3\0>\2\1\0015\2\4\0>\2\2\0015\2\5\0>\2\3\0015\2\6\0>\2\4\0015\2\a\0>\2\5\0015\2\b\0>\2\6\0015\2\t\0>\2\a\1=\1\2\0K\0\1\0\1\2\0\0005expect(\\([^. ]\\+\\))\\.to\\(_not\\|\\)': '\\1.should\\2\1\2\0\0006\\([^. ]\\+\\)\\.should\\(_not\\|\\)': 'expect(\\1)\\.to\\2\1\3\0\0\vlet g:\vvim.g.\1\3\0\0\byes\ano\1\3\0\0\b[ ]\b[x]\1\3\0\0\aif\vunless\1\3\0\0\vassert\vrefute\30switch_custom_definitions\6g\bvim\0" },
loaded = false,
needs_bufread = true,
path = "/Users/gary/.local/share/nvim/site/pack/packer/opt/switch.vim"
}
}
time("Defining packer_plugins", false)
-- Command lazy-loads
time("Defining lazy-load commands", true)
vim.cmd [[command! -nargs=* -range -bang -complete=file Switch lua require("packer.load")({'switch.vim'}, { cmd = "Switch", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]]
vim.cmd [[command! -nargs=* -range -bang -complete=file SwitchReverse lua require("packer.load")({'switch.vim'}, { cmd = "SwitchReverse", l1 = <line1>, l2 = <line2>, bang = <q-bang>, args = <q-args> }, _G.packer_plugins)]]
time("Defining lazy-load commands", false)
if should_profile then save_profiles() end
END
catch
echohl ErrorMsg
echom "Error in packer_compiled: " .. v:exception
echom "Please check your config for correctness"
echohl None
endtry
`` |
If it helps any, here it is without the lazy loaded commands: " 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 = false
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/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/gary/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/gary/.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
print('Error running ' .. component .. ' for ' .. name)
error(result)
end
return result
end
time("try_loadstring definition", false)
time("Defining packer_plugins", true)
_G.packer_plugins = {
["packer.nvim"] = {
loaded = false,
needs_bufread = false,
path = "/Users/gary/.local/share/nvim/site/pack/packer/opt/packer.nvim"
},
["switch.vim"] = {
config = { "\27LJ\2\n§\2\0\0\3\0\n\0\0196\0\0\0009\0\1\0004\1\b\0005\2\3\0>\2\1\0015\2\4\0>\2\2\0015\2\5\0>\2\3\0015\2\6\0>\2\4\0015\2\a\0>\2\5\0015\2\b\0>\2\6\0015\2\t\0>\2\a\1=\1\2\0K\0\1\0\1\2\0\0005expect(\\([^. ]\\+\\))\\.to\\(_not\\|\\)': '\\1.should\\2\1\2\0\0006\\([^. ]\\+\\)\\.should\\(_not\\|\\)': 'expect(\\1)\\.to\\2\1\3\0\0\vlet g:\vvim.g.\1\3\0\0\byes\ano\1\3\0\0\b[ ]\b[x]\1\3\0\0\aif\vunless\1\3\0\0\vassert\vrefute\30switch_custom_definitions\6g\bvim\0" },
loaded = true,
path = "/Users/gary/.local/share/nvim/site/pack/packer/start/switch.vim"
}
}
time("Defining packer_plugins", false)
-- Config for: switch.vim
time("Config for switch.vim", true)
try_loadstring("\27LJ\2\n§\2\0\0\3\0\n\0\0196\0\0\0009\0\1\0004\1\b\0005\2\3\0>\2\1\0015\2\4\0>\2\2\0015\2\5\0>\2\3\0015\2\6\0>\2\4\0015\2\a\0>\2\5\0015\2\b\0>\2\6\0015\2\t\0>\2\a\1=\1\2\0K\0\1\0\1\2\0\0005expect(\\([^. ]\\+\\))\\.to\\(_not\\|\\)': '\\1.should\\2\1\2\0\0006\\([^. ]\\+\\)\\.should\\(_not\\|\\)': 'expect(\\1)\\.to\\2\1\3\0\0\vlet g:\vvim.g.\1\3\0\0\byes\ano\1\3\0\0\b[ ]\b[x]\1\3\0\0\aif\vunless\1\3\0\0\vassert\vrefute\30switch_custom_definitions\6g\bvim\0", "config", "switch.vim")
time("Config for switch.vim", false)
if should_profile then save_profiles() end
END
catch
echohl ErrorMsg
echom "Error in packer_compiled: " .. v:exception
echom "Please check your config for correctness"
echohl None
endtry
|
Thanks! Just to confirm, the non-lazy-loaded version does not throw an error? |
Correct! |
Hmm. I'm still unable to reproduce this. Your compiled files look fine too... I've pushed a change (in 87980fc) that might help with debugging, if you can give a try. From your error message, it looks like the plugin name we try to load is not present in the table of plugins (just to check, you don't modify |
Sure! I got:
I haven't modified |
AH! I just realized what it was... I actually had a |
It might be handy for debugging to put a check if it tries to load packer twice, though! |
Thanks again for the support, though! 😄 |
Ah, whoops. That'd do it! Thanks! Unfortunately naively detecting if loading |
This still seems to be happening to me with the latest Packer 😞
While running :Switch, which should be lazy loaded, I get:
Here is my packer loading code:
Originally posted by @garymh in #180 (comment)
The text was updated successfully, but these errors were encountered: