okuuva 5e961d1e0d ci: add vimdoc auto-generation workflow (#23)
vimdoc should update on every commit to `main`. This way the "Last change" info in vimdoc actually shows when the code was last changed even if the source file for help didn't change.

Other notable changes:
- Made README.md panvimdoc compatible
  - Got rid of `<details>` and `<summary>` tags in installation instructions
  - Made title, description and badges markdown only features (not included in vimdoc)
- Tweaked README.md appearance
  - Raised all heading levels by one
  - Updated description
  - Added license badge
  - Removed customisations from badges
    - Left style as For the Badge though
- Added initial vimdoc, locally generated with panvimdoc

Closes #10.
2023-04-30 16:25:05 +03:00
2023-03-21 08:57:03 +02:00
2021-07-01 11:41:25 -05:00
2021-07-01 16:55:41 -05:00
2022-07-31 00:27:43 -05:00

🧶 auto-save.nvim

auto-save.nvim is a lua plugin for automatically saving your changed buffers in Neovim
Forked from auto-save.nvim as active development has stopped

Stars Issues License Repo Size

📋 Features

  • automatically save your changes so the world doesn't collapse
  • highly customizable:
    • conditionals to assert whether to save or not
    • execution message (it can be dimmed and personalized)
    • events that trigger auto-save
  • debounce the save with a delay
  • multiple callbacks
  • automatically clean the message area

📚 Requirements

  • Neovim >= 0.8.0

📦 Installation

Install the plugin with your favourite package manager:

Lazy.nvim

{
  "okuuva/auto-save.nvim",
  cmd = "ASToggle", -- optional for lazy loading on command
  event = { "InsertLeave", "TextChanged" } -- optional for lazy loading on trigger events
  opts = {
    -- your config goes here
    -- or just leave it empty :)
  },
},

Packer.nvim

use({
  "okuuva/auto-save.nvim",
  config = function()
   require("auto-save").setup {
     -- your config goes here
     -- or just leave it empty :)
   }
  end,
})

vim-plug

Plug 'okuuva/auto-save.nvim'
lua << EOF
  require("auto-save").setup {
    -- your config goes here
    -- or just leave it empty :)
  }
EOF

⚙️ Configuration

auto-save comes with the following defaults:

{
  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 = { "InsertLeave", "TextChanged" }, -- 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`
  debounce_delay = 1000, -- delay after which a pending save is executed
  callbacks = { -- functions to be executed at different intervals
    before_saving = nil, -- ran before doing the actual save
  },
 -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable
  debug = false,
}

Condition

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:

{
  condition = function(buf)
    local fn = vim.fn
    local utils = require("auto-save.utils.data")

    -- don't save for `sql` file types
    if utils.not_in(fn.getbufvar(buf, "&filetype"), {'sql'}) then
      return true
    end
    return false
  end
}

You may also exclude special-buffers see (:h buftype and :h special-buffers):

{
  condition = function(buf)
    local fn = vim.fn

    -- don't save for special-buffers
    if fn.getbufvar(buf, "&buftype") ~= '' then
      return false
    end
    return true
  end
}

Buffers that are nomodifiable are not saved by default.

🚀 Usage

Besides running auto-save at startup (if you have enabled = true in your config), you may as well:

  • ASToggle: toggle auto-save

You may want to set up a key mapping for toggling:

vim.api.nvim_set_keymap("n", "<leader>n", ":ASToggle<CR>", {})

or as part of the lazy.nvim plugin spec:

{
  "okuuva/auto-save.nvim",
  keys = {
    { "<leader>n", ":ASToggle<CR>", desc = "Toggle auto-save" },
  },
  ...
},

🤝 Contributing

👋 Acknowledgements

This plugin wouldn't exist without Pocco81's work on the original.

Description
🧶 Automatically save your changes in NeoVim
Readme 362 KiB
Languages
Lua 100%