Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<h2 align="center">🧶 auto-save.nvim</h2>
<h2 align="center">🧶 auto-save.nvim</h2>
</p>

<p align="center">
Expand Down Expand Up @@ -38,7 +38,7 @@ This plugin has been renamed from `AutoSave` to `auto-save`, and this repository

### 📚 Requirements

- Neovim >= 0.5.0
- Neovim >= 0.5.0

&nbsp;

Expand Down Expand Up @@ -86,15 +86,16 @@ EOF

```lua
{
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
execution_message = {
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
execution_message = {
enabled = true,
message = function() -- message to print on save
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
end,
dim = 0.18, -- dim the color of `message`
cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea
},
trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events
trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events
-- function that determines whether to save the current buffer or not
-- return true: if buffer is ok to be saved
-- return false: if it's not ok to be saved
Expand All @@ -109,8 +110,8 @@ EOF
end
return false -- can't save
end,
write_all_buffers = false, -- write all buffers when the current one meets `condition`
debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
write_all_buffers = false, -- write all buffers when the current one meets `condition`
debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds
callbacks = { -- functions to be executed at different intervals
enabling = nil, -- ran when enabling auto-save
disabling = nil, -- ran when disabling auto-save
Expand Down
1 change: 1 addition & 0 deletions lua/auto-save/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Config = {
opts = {
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
execution_message = {
enabled = true,
message = function() -- message to print on save
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
end,
Expand Down
9 changes: 8 additions & 1 deletion lua/auto-save/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ function M.save(buf)

callback("after_saving")

api.nvim_echo({ { (type(cnf.opts.execution_message.message) == "function" and cnf.opts.execution_message.message() or cnf.opts.execution_message.message), AUTO_SAVE_COLOR } }, true, {})
if cnf.opts.execution_message.enabled == true then
echo_execution_message()
end
end

local function echo_execution_message()
local msg = type(cnf.opts.execution_message.message) == "function" and cnf.opts.execution_message.message() or cnf.opts.execution_message.message
api.nvim_echo({ { msg, AUTO_SAVE_COLOR } }, true, {})
if cnf.opts.execution_message.cleaning_interval > 0 then
fn.timer_start(
cnf.opts.execution_message.cleaning_interval,
Expand Down