patch: Use Lua autocmd API - #872
Conversation
Make use of the new API implemented in neovim/neovim#14661. This API is not yet released, but will probably be released with Neovim 0.7 (see https://github.com/neovim/neovim/milestone/29). So I guess you can merge my PR when Neovim 0.7 is released? I tried out this diff on the Git master of Neovim.
|
This API will definitely be released with 0.7, which is scheduled for April 15. Be aware that until then, the API may still change! I'd recommend waiting a bit before merging this to allow people (and distros) to update (this being the Easter weekend, after all). |
| 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.
Should be init.lua, as this is Lua code.
There was a problem hiding this comment.
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.
| ``` | ||
| augroup packer_user_config | ||
| autocmd! | ||
| autocmd BufWritePost plugins.lua source <afile> | PackerCompile |
There was a problem hiding this comment.
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.
There is -- Lua callbacks get passed an args table, with args.file being equivalent to <afile>.
See :h nvim_create_autocmd().
Make use of the new API implemented in
neovim/neovim#14661.
This API is not yet released, but will probably be released with Neovim
0.7 (see https://github.com/neovim/neovim/milestone/29). So I guess you
can merge my PR when Neovim 0.7 is released?
I tried out this diff on the Git master of Neovim.