mirror of
https://github.com/zoriya/auto-save.nvim.git
synced 2025-12-06 06:36:11 +00:00
chore(doc): auto-generate vimdoc
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
*auto-save.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 October 10
|
*auto-save.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 December 04
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Table of Contents *auto-save.nvim-table-of-contents*
|
Table of Contents *auto-save.nvim-table-of-contents*
|
||||||
@@ -64,10 +64,10 @@ PACKER.NVIM *auto-save.nvim-installation-packer.nvim*
|
|||||||
"okuuva/auto-save.nvim",
|
"okuuva/auto-save.nvim",
|
||||||
tag = 'v1',
|
tag = 'v1',
|
||||||
config = function()
|
config = function()
|
||||||
require("auto-save").setup {
|
require("auto-save").setup({
|
||||||
-- your config goes here
|
-- your config goes here
|
||||||
-- or just leave it empty :)
|
-- or just leave it empty :)
|
||||||
}
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
@@ -78,10 +78,10 @@ VIM-PLUG *auto-save.nvim-installation-vim-plug*
|
|||||||
>vim
|
>vim
|
||||||
Plug 'okuuva/auto-save.nvim', { 'tag': 'v1' }
|
Plug 'okuuva/auto-save.nvim', { 'tag': 'v1' }
|
||||||
lua << EOF
|
lua << EOF
|
||||||
require("auto-save").setup {
|
require("auto-save").setup({
|
||||||
-- your config goes here
|
-- your config goes here
|
||||||
-- or just leave it empty :)
|
-- or just leave it empty :)
|
||||||
}
|
})
|
||||||
EOF
|
EOF
|
||||||
<
|
<
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ execute the event on special file patterns:
|
|||||||
{
|
{
|
||||||
trigger_events = {
|
trigger_events = {
|
||||||
immediate_save = {
|
immediate_save = {
|
||||||
{ "BufLeave", pattern = {".c", ".h"} }
|
{ "BufLeave", pattern = { ".c", ".h" } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,20 +139,18 @@ CONDITION *auto-save.nvim-configuration-condition*
|
|||||||
The `condition` field of the configuration allows the user to exclude
|
The `condition` field of the configuration allows the user to exclude
|
||||||
**auto-save** from saving specific buffers.
|
**auto-save** from saving specific buffers.
|
||||||
|
|
||||||
Here is an example using a helper function from `auto-save.utils.data` that
|
Here is an example that disables auto-save for specified file types:
|
||||||
disables auto-save for specified file types:
|
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
{
|
{
|
||||||
condition = function(buf)
|
condition = function(buf)
|
||||||
local fn = vim.fn
|
local filetype = vim.fn.getbufvar(buf, "&filetype")
|
||||||
local utils = require("auto-save.utils.data")
|
|
||||||
|
|
||||||
-- don't save for `sql` file types
|
-- don't save for `sql` file types
|
||||||
if utils.not_in(fn.getbufvar(buf, "&filetype"), {'sql'}) then
|
if vim.list_contains({ "sql" }, filetype) then
|
||||||
return true
|
return false
|
||||||
end
|
end
|
||||||
return false
|
return true
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
@@ -163,10 +161,8 @@ special-buffers`):
|
|||||||
>lua
|
>lua
|
||||||
{
|
{
|
||||||
condition = function(buf)
|
condition = function(buf)
|
||||||
local fn = vim.fn
|
|
||||||
|
|
||||||
-- don't save for special-buffers
|
-- don't save for special-buffers
|
||||||
if fn.getbufvar(buf, "&buftype") ~= '' then
|
if vim.fn.getbufvar(buf, "&buftype") ~= '' then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -188,7 +184,7 @@ config), you may as well:
|
|||||||
You may want to set up a key mapping for toggling:
|
You may want to set up a key mapping for toggling:
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
vim.api.nvim_set_keymap("n", "<leader>n", ":ASToggle<CR>", {})
|
vim.api.nvim_set_keymap("n", "<leader>n", "<cmd>ASToggle<CR>", {})
|
||||||
<
|
<
|
||||||
|
|
||||||
or as part of the `lazy.nvim` plugin spec:
|
or as part of the `lazy.nvim` plugin spec:
|
||||||
@@ -197,7 +193,7 @@ or as part of the `lazy.nvim` plugin spec:
|
|||||||
{
|
{
|
||||||
"okuuva/auto-save.nvim",
|
"okuuva/auto-save.nvim",
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>n", ":ASToggle<CR>", desc = "Toggle auto-save" },
|
{ "<leader>n", "<cmd>ASToggle<CR>", desc = "Toggle auto-save" },
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
},
|
},
|
||||||
@@ -228,12 +224,34 @@ An example to print a message with the file name after a file got saved:
|
|||||||
callback = function(opts)
|
callback = function(opts)
|
||||||
if opts.data.saved_buffer ~= nil then
|
if opts.data.saved_buffer ~= nil then
|
||||||
local filename = vim.api.nvim_buf_get_name(opts.data.saved_buffer)
|
local filename = vim.api.nvim_buf_get_name(opts.data.saved_buffer)
|
||||||
print('AutoSave: saved ' .. filename .. ' at ' .. vim.fn.strftime('%H:%M:%S'))
|
vim.notify('AutoSave: saved ' .. filename .. ' at ' .. vim.fn.strftime('%H:%M:%S'), vim.log.levels.INFO)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
|
|
||||||
|
Another example to print a message when enabling/disabling autosave:
|
||||||
|
|
||||||
|
>lua
|
||||||
|
local group = vim.api.nvim_create_augroup('autosave', {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('User', {
|
||||||
|
pattern = 'AutoSaveEnable',
|
||||||
|
group = group,
|
||||||
|
callback = function(opts)
|
||||||
|
vim.notify('AutoSave enabled', vim.log.levels.INFO)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('User', {
|
||||||
|
pattern = 'AutoSaveDisable',
|
||||||
|
group = group,
|
||||||
|
callback = function(opts)
|
||||||
|
vim.notify('AutoSave disabled', vim.log.levels.INFO)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
<
|
||||||
|
|
||||||
If you want more Events, feel free to open an issue.
|
If you want more Events, feel free to open an issue.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user