feat: allow to disable execution_message

Squashed changes from https://github.com/Pocco81/auto-save.nvim/pull/50
Got too hairy for a GH noob like me to fix properly.
This commit is contained in:
Jakub Łuczyński
2022-08-16 14:05:42 +02:00
committed by Oula Kuuva
parent 492bab0c47
commit 4db41a2155
3 changed files with 17 additions and 16 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -82,15 +82,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, function()
cmd([[echon '']])