Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b84acda8a4
|
No files matched your search
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.1.1] - 2026-04-09
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Save after normal mode changes (undo, redo, paste, delete) by adding
|
||||||
|
`TextChanged` to default events
|
||||||
|
|
||||||
## [0.1.0] - 2026-04-09
|
## [0.1.0] - 2026-04-09
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -14,4 +21,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Configurable trigger events
|
- Configurable trigger events
|
||||||
- Zero-config auto-loading via `plugin/` directory
|
- Zero-config auto-loading via `plugin/` directory
|
||||||
|
|
||||||
|
[0.1.1]: https://github.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.1
|
||||||
[0.1.0]: https://github.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.0
|
[0.1.0]: https://github.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.0
|
||||||
@@ -7,7 +7,7 @@ Zero config. ~15 lines of Lua.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Auto-saves on leaving insert mode and losing focus
|
- Auto-saves on leaving insert mode, normal mode changes (undo, paste, etc.), and losing focus
|
||||||
- Only saves normal file buffers (skips special buffers)
|
- Only saves normal file buffers (skips special buffers)
|
||||||
- Configurable trigger events
|
- Configurable trigger events
|
||||||
- Works out of the box — no setup call required
|
- Works out of the box — no setup call required
|
||||||
@@ -32,7 +32,7 @@ All options are optional. Call `setup()` only if you want to customize:
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
require("tiny-autosave").setup({
|
require("tiny-autosave").setup({
|
||||||
events = { "InsertLeave", "FocusLost" }, -- events that trigger save
|
events = { "InsertLeave", "TextChanged", "FocusLost" }, -- events that trigger save
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
*tiny-autosave.txt* Auto-save buffers on InsertLeave and FocusLost
|
*tiny-autosave.txt* Auto-save buffers on text changes and focus loss
|
||||||
|
|
||||||
Author: Stephen Waits <https://github.com/swaits>
|
Author: Stephen Waits <https://github.com/swaits>
|
||||||
License: MIT
|
License: MIT
|
||||||
@@ -15,7 +15,8 @@ CONTENTS *tiny-autosave-contents*
|
|||||||
1. INTRODUCTION *tiny-autosave-introduction*
|
1. INTRODUCTION *tiny-autosave-introduction*
|
||||||
|
|
||||||
tiny-autosave.nvim automatically saves modified buffers when leaving insert
|
tiny-autosave.nvim automatically saves modified buffers when leaving insert
|
||||||
mode or when Neovim loses focus. Works out of the box with zero configuration.
|
mode, after normal mode changes (undo, paste, etc.), and when Neovim loses
|
||||||
|
focus. Works out of the box with zero configuration.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
2. REQUIREMENTS *tiny-autosave-requirements*
|
2. REQUIREMENTS *tiny-autosave-requirements*
|
||||||
@@ -32,7 +33,7 @@ Add to your |vim.pack.add()| call: >lua
|
|||||||
That's it. The plugin auto-loads with defaults. To customize, call setup: >lua
|
That's it. The plugin auto-loads with defaults. To customize, call setup: >lua
|
||||||
|
|
||||||
require("tiny-autosave").setup({
|
require("tiny-autosave").setup({
|
||||||
events = { "InsertLeave", "FocusLost" },
|
events = { "InsertLeave", "TextChanged", "FocusLost" },
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -47,7 +48,7 @@ setup({opts})
|
|||||||
All options shown with defaults: >lua
|
All options shown with defaults: >lua
|
||||||
|
|
||||||
require("tiny-autosave").setup({
|
require("tiny-autosave").setup({
|
||||||
events = { "InsertLeave", "FocusLost" },
|
events = { "InsertLeave", "TextChanged", "FocusLost" },
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
@@ -55,7 +56,7 @@ setup({opts})
|
|||||||
|
|
||||||
Fields: ~
|
Fields: ~
|
||||||
{events} (table) List of events that trigger auto-save.
|
{events} (table) List of events that trigger auto-save.
|
||||||
Default: { "InsertLeave", "FocusLost" }
|
Default: { "InsertLeave", "TextChanged", "FocusLost" }
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim:tw=78:ts=8:ft=help:norl:
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
@@ -2,13 +2,20 @@ local M = {}
|
|||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local events = opts.events or { "InsertLeave", "FocusLost" }
|
local events = opts.events or { "InsertLeave", "TextChanged", "FocusLost" }
|
||||||
|
|
||||||
|
vim.opt.autowrite = true
|
||||||
|
vim.opt.autowriteall = true
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd(events, {
|
vim.api.nvim_create_autocmd(events, {
|
||||||
group = vim.api.nvim_create_augroup("tiny-autosave", { clear = true }),
|
group = vim.api.nvim_create_augroup("tiny-autosave", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.bo.buftype == "" and vim.bo.modified then
|
local name = vim.api.nvim_buf_get_name(0)
|
||||||
vim.cmd("silent! wall")
|
if name ~= "" and vim.fn.filereadable(name) == 0 then
|
||||||
|
vim.fn.mkdir(vim.fn.fnamemodify(name, ":p:h"), "p")
|
||||||
end
|
end
|
||||||
|
vim.cmd("silent! write")
|
||||||
|
vim.cmd("silent! wall")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user