-
-
Notifications
You must be signed in to change notification settings - Fork 265
patch: Use Lua autocmd API #872
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| 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. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. However, I see that there are other references to |
||
|
|
||
| ## Bootstrapping | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.There was a problem hiding this comment.
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
argstable, withargs.filebeing equivalent to<afile>.See
:h nvim_create_autocmd().