Skip to content
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

bug: lazy.nvim hides print() output for files in plugin/* #336

Closed
3 tasks done
andrewferrier opened this issue Jan 6, 2023 · 2 comments · Fixed by #329
Closed
3 tasks done

bug: lazy.nvim hides print() output for files in plugin/* #336

andrewferrier opened this issue Jan 6, 2023 · 2 comments · Fixed by #329
Labels
bug Something isn't working

Comments

@andrewferrier
Copy link

andrewferrier commented Jan 6, 2023

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

v0.9.0-dev-622+g08ebf8d3a

Operating system/version

Linux lawn 6.1.3-arch1-1

Describe the bug

I split up my personal configuration so that the majority of what many people put in ~/.config/nvim/init.lua is in files in ~/.config/nvim/plugins/*.lua. I think this is a moderately-common pattern, and one that NeoVim supports by default.

Since lazy.nvim takes over the process of loading the files in plugins/, it appears that configuration loaded that way no longer outputs print() statements that would normally output at startup (I've also tried vim.cmd('echo "xyz"') too). They don't appear in :messages.

This is not much more than annoying at this stage, since it makes debugging my configuration trickier.

I would assume this is happening because lazy.nvim is pre-compiling this code, and perhaps there is an optimization which removes print()? I'm not sure if this is deliberate, however. Certainly I would argue it's not correct - there are many legitimate reasons to want to print() during startup, even if it's not that common.

Thanks as always for all your hard work on the plugin.

Steps To Reproduce

  1. Create ./.repro/config/nvim/plugins/x.lua containing just print('foo').
  2. Run NeoVim with repro init.lua as below.
  3. Type :messages.
  4. bar is printed from init.lua, but not foo from x.lua.

Expected Behavior

Both foo and bar are printed.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

print('bar')
@andrewferrier andrewferrier added the bug Something isn't working label Jan 6, 2023
@folke folke closed this as completed in 102bc27 Jan 6, 2023
@folke
Copy link
Owner

folke commented Jan 6, 2023

I don't remember why, but for some reason I did silent source plugin/*. That silent obviously should not be there. Fixed now!

@andrewferrier
Copy link
Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants