From b014ec8349cee9315ee8319410070e2c3284ba6d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20=C5=81uczy=C5=84ski?=
Date: Tue, 16 Aug 2022 14:05:42 +0200
Subject: [PATCH 1/2] README: Fix whitespaces
---
README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 12089e3..202faa0 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
๐งถ auto-save.nvim
+ ๐งถ auto-save.nvim
@@ -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
@@ -86,15 +86,15 @@ 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 = {
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
@@ -109,8 +109,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
From 7b5204b2255a1687f670341c9db4713a2fa6f2a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20=C5=81uczy=C5=84ski?=
Date: Tue, 16 Aug 2022 14:07:37 +0200
Subject: [PATCH 2/2] feat: allow to disable execution_message
---
README.md | 1 +
lua/auto-save/config.lua | 1 +
lua/auto-save/init.lua | 9 ++++++++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 202faa0..36a9174 100644
--- a/README.md
+++ b/README.md
@@ -88,6 +88,7 @@ EOF
{
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,
diff --git a/lua/auto-save/config.lua b/lua/auto-save/config.lua
index 2dfcc73..85ab3ac 100644
--- a/lua/auto-save/config.lua
+++ b/lua/auto-save/config.lua
@@ -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,
diff --git a/lua/auto-save/init.lua b/lua/auto-save/init.lua
index 0f5fed1..0bd427c 100644
--- a/lua/auto-save/init.lua
+++ b/lua/auto-save/init.lua
@@ -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,