aboutsummaryrefslogtreecommitdiffhomepage
path: root/.config/nvim/lua/autosave.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/autosave.lua')
-rw-r--r--.config/nvim/lua/autosave.lua25
1 files changed, 11 insertions, 14 deletions
diff --git a/.config/nvim/lua/autosave.lua b/.config/nvim/lua/autosave.lua
index ae481ed..cba48fb 100644
--- a/.config/nvim/lua/autosave.lua
+++ b/.config/nvim/lua/autosave.lua
@@ -2,7 +2,7 @@ local M = {}
local INTERVAL_MS = 10 * 1000
-local SILENT = true
+local SILENT = false
-- Because a timer cannot be converted to Vim value,
@@ -10,6 +10,13 @@ local SILENT = true
local timers = {}
+local function echo(text, hl_group)
+ if SILENT then return end
+
+ vim.api.nvim_echo({{ text, hl_group }}, false, {})
+end
+
+
local function handler()
if not vim.bo.modified then
return
@@ -24,19 +31,9 @@ local function handler()
return
end
- if not SILENT then
- vim.cmd([[echohl Comment]])
- vim.cmd([[echo 'Auto-saving...']])
- vim.cmd([[echohl None]])
- end
-
- vim.cmd([[silent! write]])
-
- if not SILENT then
- vim.cmd([[echohl Comment]])
- vim.cmd([[echo 'Saved.']])
- vim.cmd([[echohl None]])
- end
+ echo('Auto-saving...', 'Comment')
+ vim.cmd('silent! write')
+ echo('Saved.', 'Comment')
end