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: Plugin does not attach on initial buffer if lazy loaded #57

Open
gregorias opened this issue Apr 2, 2023 · 1 comment
Open

Bug: Plugin does not attach on initial buffer if lazy loaded #57

gregorias opened this issue Apr 2, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@gregorias
Copy link

Describe the bug
Plugin does not attach on initial buffer if lazy loaded with Lazy.

To Reproduce

Using Lazy plugin manager, configure your nvim-colorizer like so:

  { 'NvChad/nvim-colorizer.lua',
    config = function() require'colorizer'.setup{} end,
    event = 'VeryLazy',
  },

Then, create a sample file:

echo "#111" > foo

Open it with Neovim:

nvim cos

You won't see #111 colorized.

Expected behavior

#111 is colorized.

Colorizer Version:
dde3084

Additional context
I've added the following to my config to address this issue, but I think it'd be worthwhile to just do it upstream in setup.

	{ 'NvChad/nvim-colorizer.lua',
		config = function()
			local c = require'colorizer'
			c.setup{}

			-- nvim-colorizer doesn't work on the initial buffer if we lazy load, so force it to attach
			-- on load.
			local bufnr = vim.api.nvim_get_current_buf()
			if bufnr and not c.is_buffer_attached(bufnr) then
				c.attach_to_buffer(bufnr)
			end
		end,
		event = 'VeryLazy',},
@gregorias gregorias added the bug Something isn't working label Apr 2, 2023
@sscherfke
Copy link

This is also the case when you do lazy = true instead of event = "VeryLazy".

Workaround: Use neither of those options or event = { "BufReadPost", "BufNewFile" },

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

No branches or pull requests

3 participants