Skip to content

Commit

Permalink
chore!: Remove unneeded utils and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
primeapple committed Oct 14, 2024
1 parent 5fbcaac commit 0d7e526
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 58 deletions.
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ use({
"okuuva/auto-save.nvim",
tag = 'v1*',
config = function()
require("auto-save").setup {
require("auto-save").setup({
-- your config goes here
-- or just leave it empty :)
}
})
end,
})
```
Expand All @@ -78,10 +78,10 @@ use({
```vim
Plug 'okuuva/auto-save.nvim', { 'tag': 'v1*' }
lua << EOF
require("auto-save").setup {
require("auto-save").setup({
-- your config goes here
-- or just leave it empty :)
}
})
EOF
```

Expand Down Expand Up @@ -124,7 +124,7 @@ It is also possible to pass a pattern to a trigger event, if you only want to ex
{
trigger_events = {
immediate_save = {
{ "BufLeave", pattern = {"*.c", "*.h"} }
{ "BufLeave", pattern = { "*.c", "*.h" } }
}
}
}
Expand All @@ -134,16 +134,15 @@ It is also possible to pass a pattern to a trigger event, if you only want to ex

The `condition` field of the configuration allows the user to exclude **auto-save** from saving specific buffers.

Here is an example using a helper function from `auto-save.utils.data` that disables auto-save for specified file types:
Here is an example using a helper function that disables auto-save for specified file types:

```lua
{
condition = function(buf)
local fn = vim.fn
local utils = require("auto-save.utils.data")
local filetype = vim.fn.getbufvar(buf, "&filetype")

-- 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
end
return false
Expand All @@ -156,8 +155,6 @@ You may also exclude `special-buffers` see (`:h buftype` and `:h special-buffers
```lua
{
condition = function(buf)
local fn = vim.fn

-- don't save for special-buffers
if fn.getbufvar(buf, "&buftype") ~= '' then
return false
Expand All @@ -178,7 +175,7 @@ Besides running auto-save at startup (if you have `enabled = true` in your confi
You may want to set up a key mapping for toggling:

```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:
Expand All @@ -187,7 +184,7 @@ or as part of the `lazy.nvim` plugin spec:
{
"okuuva/auto-save.nvim",
keys = {
{ "<leader>n", ":ASToggle<CR>", desc = "Toggle auto-save" },
{ "<leader>n", "<cmd>ASToggle<CR>", desc = "Toggle auto-save" },
},
...
},
Expand Down
3 changes: 0 additions & 3 deletions lua/auto-save/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local M = {}

--- @class Config
local cnf = require("auto-save.config")
local echo = require("auto-save.utils.echo")
local autocmds = require("auto-save.utils.autocommands")

local api = vim.api
Expand Down Expand Up @@ -155,10 +154,8 @@ end
function M.toggle()
if autosave_running then
M.off()
echo("off")
else
M.on()
echo("on")
end
end

Expand Down
17 changes: 0 additions & 17 deletions lua/auto-save/utils/data.lua

This file was deleted.

25 changes: 0 additions & 25 deletions lua/auto-save/utils/echo.lua

This file was deleted.

0 comments on commit 0d7e526

Please sign in to comment.