From ed4676be72d3ce09e8df2080a8496a4931a1b5be Mon Sep 17 00:00:00 2001 From: veypi Date: Mon, 25 Sep 2023 17:41:10 +0800 Subject: [PATCH] add autosave --- lazy-lock.json | 1 + lua/plugins.lua | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/lazy-lock.json b/lazy-lock.json index a07331a..95f1101 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,6 +2,7 @@ "Comment.nvim": { "branch": "master", "commit": "38d3b7eb553872d8866f14a0dd4fe84126068fce" }, "LuaSnip": { "branch": "master", "commit": "e77fa9ad0b1f4fc6cddf54e51047e17e90c7d7ed" }, "alpha-nvim": { "branch": "main", "commit": "87c204040e3f5d4c1c95067b35905d8f8a2f2545" }, + "auto-save.nvim": { "branch": "main", "commit": "610e72307d675fcc15098c5a435ad89e45aaf855" }, "bigfile.nvim": { "branch": "main", "commit": "c1bad34ce742b4f360b67ca23c873fef998240fc" }, "bufferline.nvim": { "branch": "main", "commit": "a4bd44523316928a7c4a5c09a3407d02c30b6027" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, diff --git a/lua/plugins.lua b/lua/plugins.lua index 23220c5..dd7b939 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -4,6 +4,38 @@ lvim.plugins = { config = function() end, }, + { + "okuuva/auto-save.nvim", + config = function() + require("auto-save").setup { + 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 = { -- See :h events + immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save + defer_save = {}, -- vim events that trigger a deferred save (saves after `debounce_delay`) + -- cancel_defered_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save + }, + -- function that takes the buffer handle and 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 + -- if set to `nil` then no specific condition is applied + condition = nil, + + write_all_buffers = false, -- write all buffers when the current one meets `condition` + noautocmd = false, -- do not execute autocmds when saving + debounce_delay = 1000, -- delay after which a pending save is executed + -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable + debug = false, + } + end, + }, { "windwp/nvim-ts-autotag", config = function()