4 Commits
Author SHA1 Message Date
swaits 016ca89f87 chore: repoint remaining links and host-specific tooling at git.swaits.com
CI / lint (push) Canceled after 0s
CI / test (push) Canceled after 0s
Covers files missed by the first pass (.svelte/.astro components, bare org and
profile links, plugin doc headers), plus content that needed rewriting rather
than a URL swap: the chezmoi bootstrap script now provisions SSH for
git.swaits.com (User git, port 2222) and initialises from Gitea.

Link labels were updated to match their new targets.
2026-08-31 18:35:25 -06:00
swaits e95071442b chore: repoint remaining links at git.swaits.com
CI / lint (push) Canceled after 0s
CI / test (push) Canceled after 0s
Rewrites lingering github.com / *.sr.ht references to this Gitea instance,
translating GitHub and Sourcehut URL shapes to Gitea's (/blob/<ref>/ and
sr.ht /tree/<ref>/item/ -> /src/branch/<ref>/, /tree/<tag> -> /src/tag/<tag>,
/actions/workflows/X -> /actions?workflow=X, /edit/ -> /_edit/).

Left pointing at the old hosts on purpose: pull-request links (PRs were not
migrated), forks that were never migrated, and GitHub-only surfaces Gitea
lacks. OpenPGP identity proofs are untouched by design.
2026-08-31 18:32:25 -06:00
swaits c06115fa81 chore: release 0.1.2
CI / lint (push) Canceled after 0s
CI / test (push) Canceled after 0s
### Fixed

- `BufWritePre` formatters (e.g. conform.nvim format-on-save) now run on
  autosave. The trigger autocmd now uses `nested = true`, so the `:write`
  invoked from inside the `InsertLeave` / `TextChanged` / `FocusLost`
  handler fires nested autocmds (see `:help autocmd-nested`).

### Changed

- Skip saves for unmodified, unnamed, or special (`buftype`) buffers instead
  of always attempting a write.
- Drop `:wall` — autosave only writes the buffer the event fired on.
- Use `silent` (not `silent!`) so write errors surface instead of being
  swallowed.
2026-04-12 20:12:03 -06:00
swaits b84acda8a4 fix: set autowrite/autowriteall, handle never-saved buffers 2026-04-09 19:30:46 -06:00
5 changed files with 107 additions and 15 deletions

No files matched your search

+27 -1
View File
@@ -5,6 +5,30 @@ 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.2] - 2026-04-12
### Fixed
- `BufWritePre` formatters (e.g. conform.nvim format-on-save) now run on
autosave. The trigger autocmd now uses `nested = true`, so the `:write`
invoked from inside the `InsertLeave` / `TextChanged` / `FocusLost`
handler fires nested autocmds (see `:help autocmd-nested`).
### Changed
- Skip saves for unmodified, unnamed, or special (`buftype`) buffers instead
of always attempting a write.
- Drop `:wall` — autosave only writes the buffer the event fired on.
- Use `silent` (not `silent!`) so write errors surface instead of being
swallowed.
## [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 +38,6 @@ 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.0]: https://github.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.0 [0.1.2]: https://git.swaits.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.2
[0.1.1]: https://git.swaits.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.1
[0.1.0]: https://git.swaits.com/swaits/tiny-autosave.nvim/releases/tag/v0.1.0
+3 -3
View File
@@ -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
@@ -21,7 +21,7 @@ Zero config. ~15 lines of Lua.
Add to your `vim.pack.add()` call: Add to your `vim.pack.add()` call:
```lua ```lua
"https://github.com/swaits/tiny-autosave.nvim", "https://git.swaits.com/swaits/tiny-autosave.nvim",
``` ```
Done. The plugin auto-loads with sensible defaults. Done. The plugin auto-loads with sensible defaults.
@@ -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
}) })
``` ```
+8 -7
View File
@@ -1,6 +1,6 @@
*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://git.swaits.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*
@@ -27,12 +28,12 @@ mode or when Neovim loses focus. Works out of the box with zero configuration.
Add to your |vim.pack.add()| call: >lua Add to your |vim.pack.add()| call: >lua
"https://github.com/swaits/tiny-autosave.nvim", "https://git.swaits.com/swaits/tiny-autosave.nvim",
< <
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:
+20 -4
View File
@@ -2,13 +2,29 @@ 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() nested = true,
if vim.bo.buftype == "" and vim.bo.modified then callback = function(args)
vim.cmd("silent! wall") local buf = args.buf
if vim.bo[buf].buftype ~= "" or not vim.bo[buf].modified then
return
end end
local name = vim.api.nvim_buf_get_name(buf)
if name == "" then
return
end
if vim.fn.filereadable(name) == 0 then
vim.fn.mkdir(vim.fn.fnamemodify(name, ":p:h"), "p")
end
vim.api.nvim_buf_call(buf, function()
vim.cmd("silent keepalt keepjumps write")
end)
end, end,
}) })
end end
+49
View File
@@ -21,4 +21,53 @@ T["setup"]["respects custom events"] = function()
eq(#groups, 1) eq(#groups, 1)
end end
T["save"] = MiniTest.new_set()
T["save"]["fires BufWritePre once and applies formatter changes"] = function()
require("tiny-autosave").setup()
local tmp = vim.fn.tempname() .. ".txt"
vim.cmd("edit " .. tmp)
local buf = vim.api.nvim_get_current_buf()
local pre_count = 0
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = buf,
callback = function()
pre_count = pre_count + 1
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "formatted" })
end,
})
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "original", "", "", "" })
vim.api.nvim_exec_autocmds("InsertLeave", { buffer = buf })
eq(pre_count, 1)
eq(vim.fn.readfile(tmp), { "formatted" })
os.remove(tmp)
end
T["save"]["skips unnamed buffers"] = function()
require("tiny-autosave").setup()
vim.cmd("enew")
local buf = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "scratch" })
local ok = pcall(vim.api.nvim_exec_autocmds, "InsertLeave", {})
eq(ok, true)
end
T["save"]["skips unmodified buffers"] = function()
require("tiny-autosave").setup()
local tmp = vim.fn.tempname() .. ".txt"
vim.fn.writefile({ "hello" }, tmp)
vim.cmd("edit " .. tmp)
local buf = vim.api.nvim_get_current_buf()
local pre_count = 0
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = buf,
callback = function()
pre_count = pre_count + 1
end,
})
vim.api.nvim_exec_autocmds("InsertLeave", { buffer = buf })
eq(pre_count, 0)
os.remove(tmp)
end
return T return T