Repository navigation
v0.4.0
What's Changed
Features
Autocmds
- Add default autocmds with per-autocmd opt-out by @nmfirdausw in #4
Highlights
- Default autocmds. Batu now ships a small set of autocmds that smooth over everyday editing.
- Yours to turn off. The
autocmdsoption disables any of them by name, or all of them at once. - Native. Plain
vim.api.nvim_create_autocmdcalls under onebatu.autocmdsaugroup, with no dependencies.
Default autocmds
| Name | Event | Action |
|---|---|---|
highlight_yank |
TextYankPost |
Briefly highlight yanked text |
restore_cursor |
BufReadPost |
Restore the cursor to its last known position when reopening a file |
auto_create_dir |
BufWritePre |
Create missing parent directories before writing a file |
auto_reload |
FocusGained, BufEnter |
Reload buffers changed on disk outside of Neovim |
close_with_q |
FileType |
Close help, quickfix, man and similar buffers with q |
Usage
require("batu").setup({
autocmds = {
highlight_yank = false, -- skip a default
},
})| Option | Value | Effect |
|---|---|---|
autocmds |
true (default) |
Create Batu's default autocmds |
false |
Create none, and never load the module | |
| a table | Create the defaults except those set to false, by name |
How it works
All autocmds share the batu.autocmds augroup, so they are cleared and recreated cleanly if setup() runs again. A name in the table that Batu doesn't know produces a warning instead of being ignored silently.
auto_create_dir skips URL-style buffers such as oil:// or scp://, so it never creates stray local directories for them. close_with_q applies to the help, qf, man, lspinfo and checkhealth filetypes.
Upgrading
Like v0.3.0, existing configs will notice this release. autocmds is on by default, so setup() now creates the autocmds above.
- To keep your current setup, use
setup({ autocmds = false }). - To drop one autocmd, set it to
false, for exampleautocmds = { auto_reload = false }. - If you already create similar autocmds yourself, they run alongside Batu's. Disable the matching one to avoid doing the work twice.
Full Changelog: v0.3.0...v0.4.0