An open API service indexing awesome lists of open source software.

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.

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.|