mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-16 12:14:32 +02:00
plugins/auto-save: init + test
This commit is contained in:
parent
1262c0d54f
commit
1f285df664
3 changed files with 205 additions and 0 deletions
47
tests/test-sources/plugins/utils/auto-save.nix
Normal file
47
tests/test-sources/plugins/utils/auto-save.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.auto-save.enable = true;
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.auto-save = {
|
||||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
toggle = "<leader>s";
|
||||
};
|
||||
enableAutoSave = true;
|
||||
executionMessage = {
|
||||
message.__raw = ''
|
||||
function()
|
||||
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
|
||||
end
|
||||
'';
|
||||
dim = 0.18;
|
||||
cleaningInterval = 1250;
|
||||
};
|
||||
triggerEvents = ["InsertLeave" "TextChanged"];
|
||||
condition = ''
|
||||
function(buf)
|
||||
local fn = vim.fn
|
||||
local utils = require("auto-save.utils.data")
|
||||
|
||||
if fn.getbufvar(buf, "&modifiable") == 1 and utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
|
||||
return true -- met condition(s), can save
|
||||
end
|
||||
return false -- can't save
|
||||
end
|
||||
'';
|
||||
writeAllBuffers = false;
|
||||
debounceDelay = 135;
|
||||
callbacks = {
|
||||
enabling = null;
|
||||
disabling = null;
|
||||
beforeAssertingSave = null;
|
||||
beforeSaving = null;
|
||||
afterSaving = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue