Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,15 @@ You can configure Neovim to automatically run `:PackerCompile` whenever `plugins
[an autocommand](https://neovim.io/doc/user/autocmd.html#:autocmd):

```
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is source <afile> not needed anymore?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with what source <afile> does. If I remember correctly I tried to find the equivalent in the lua api and there was nothing equivalent (but maybe I remember that wrong). I have the lua code in my init.lua as I wrote in this PR and it works.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is -- Lua callbacks get passed an args table, with args.file being equivalent to <afile>.

See :h nvim_create_autocmd().

augroup end
local group = vim.api.nvim_create_augroup("packer_user_config", { clear = true })
vim.api.nvim_create_autocmd("BufWritePost", {
command = "PackerCompile",
pattern = "plugins.lua",
group = group,
})
```

This autocommand can be placed in your `init.vim`, or any other startup file as per your setup.
Placing this in `plugins.lua` could look like this:

```lua
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
```
This autocommand can be placed in your `init.vim`, in `plugins.lua`, or any other startup file as per your setup.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be init.lua, as this is Lua code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. However, I see that there are other references to init.vim in the readme. I guess it would be inconsistent if I used init.lua in this one place and the rest of the readme uses init.vim. I dropped the reference to init.vim entirely for now, I think that's probably the easiest solution.


## Bootstrapping

Expand Down