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

fix(event): fix running BufRead cmd when plugin loaded by BufRead #788

Closed
wants to merge 1 commit into from

Conversation

fent
Copy link

@fent fent commented May 9, 2023

Hello there, ran into a bug where a plugin that is lazy loaded using the event BufRead and also sets up an autocmd that uses BufRead during setup, the autocmd won't run. This is because vim.api.nvim_get_autocmds({ event = "BufRead" }) returns objects with the event as BufReadPost and not as BufRead

I tested using the following plugin. with the fix, the autocmd callback fires, without it it doesn't

  {
    "Abstract-IDE/Abstract-cs", -- plugin doesn't matter, just grabbed a random colorscheme
    event = "BufRead",
    config = function()
      print("plugin 1 config")
      vim.api.nvim_create_autocmd("BufRead", {
        pattern = "*",
        callback = function()
          print("plugin 1 autocmd!")
        end,
        group = vim.api.nvim_create_augroup("mygroup1", {}),
      })
    end
  },

this change removes M.trigger_events, i didn't fully understand the purpose of this table, so if i made a mistake removing it please let me know. i removed it because i removed the check for autocmd.event == event in this line

@folke folke closed this in ef2a5d0 Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant