https://github.com/h3pei/autosave.nvim
A Neovim plugin that provide autosave functionality.
https://github.com/h3pei/autosave.nvim
lua neovim
Last synced: about 1 month ago
JSON representation
A Neovim plugin that provide autosave functionality.
- Host: GitHub
- URL: https://github.com/h3pei/autosave.nvim
- Owner: h3pei
- License: mit
- Created: 2022-11-04T09:12:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-08-16T08:15:03.000Z (8 months ago)
- Last Synced: 2025-10-19T02:34:40.237Z (6 months ago)
- Topics: lua, neovim
- Language: Lua
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# autosave.nvim
Provide autosave functionality to Neovim.
Inspired by [vim-auto-save](https://github.com/vim-scripts/vim-auto-save).
## Installation
[packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
use { "h3pei/autosave.nvim" }
```
[vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug "h3pei/autosave.nvim"
```
## Usage
All you have to do is call the `setup()` function.
```lua
require('autosave').setup()
```
### Configuration
Some behaviors are customizable.
```lua
-- default settings
require('autosave').setup({
enabled = true,
silent = false,
autosave_events = { "InsertLeave", "TextChanged", "CursorHold" },
postsave_hook = nil,
exclude_filetypes = {},
})
```
#### enabled (type: boolean)
Default: `true`
If `true`, autosave is enabled.
#### silent (type: boolean)
Default: `false`
If `true`, no message is output during autosave.
#### autosave_events (type: table)
Default: `{ "InsertLeave", "TextChanged", "CursorHold" }`
Events that perform autosave.
If you want to enable autosave even while in INSERT mode, you may additionally specify `CursorHoldI` and `CompleteDone`.
See `:help events` for more information about events.
#### postsave_hook (type: function)
Default: `nil`
Specify the process you want to perform after auto save as a lua function.
#### exclude_filetypes (type: table)
Default: `{}`
List of filetypes for which autosave should be disabled.
For example, to disable autosave for oil.nvim buffers:
```lua
require('autosave').setup({
exclude_filetypes = { "oil" },
})
```
### Commands
Several useful commands are built-in.
|Command|Description|
|:--|:--|
|`:AutosaveEnable`|Enable autosave.|
|`:AutosaveDisable`|Disable autosave.|
|`:AutosaveToggle`|Toggle autosave.|