wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.87k stars 267 forks source link

`after` key can't guarantee the loading order of plugins if also specifing autocommand `event` #1037

Closed younger-1 closed 2 years ago

younger-1 commented 2 years ago

Steps to reproduce

When use after key together with event key like this one:

    use {
      'mfussenegger/nvim-dap',
      module = 'dap',
    }
    use {
      'rcarriga/nvim-dap-ui',
      event = 'BufRead',
      after = 'nvim-dap',
    }

Actual behaviour

nvim-dap-ui will be loaded before nvim-dap 图片

Expected behaviour

the plugin nvim-dap-ui will only be loaded after the plugin nvim-dap loaded 图片

packer files

Plugin specification file(s) Post or link your plugin specification files here, if you aren't able to provide a minimal reproducer
packer log file Post the contents of ~/.cache/nvim/packer.nvim.log here
packer compiled file Post the contents of `packer_compiled.vim` here
EdenEast commented 2 years ago

The keys event and after both deal with when a plugin is loaded by packer. For the ui plugin spec you are saying that you want to load 'ui' either on BufRead events or after dap is loaded. after tells packer that something should be loaded after another plugin is loaded. This dose not say that when ui is loaded that it should also load dap. This would be requires.

dap will only be loaded when require('dap') is called (because the module key is used).

Hope that clarifies it.

younger-1 commented 2 years ago

Thanks your explanation~