diff options
Diffstat (limited to '.config/nvim/plugin/50-format.lua')
| -rw-r--r-- | .config/nvim/plugin/50-format.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/.config/nvim/plugin/50-format.lua b/.config/nvim/plugin/50-format.lua index e021227..d77f1fd 100644 --- a/.config/nvim/plugin/50-format.lua +++ b/.config/nvim/plugin/50-format.lua @@ -39,7 +39,7 @@ formatters.bash = formatters.sh --- Format the buffer `ev.buf` with the formatter for its filetype. --- This function is meant to be an event handler for `vim.api.nvim_create_autocmd()` --- @param ev table `ev` argument passed from `vim.api.nvim_create_autocmd()` -local function on_format(ev) +local function format_buffer(ev) if vim.b[ev.buf].format ~= true then return end @@ -59,10 +59,12 @@ local function on_format(ev) vim.fn.winrestview(view) end +---------------------------------------------------------------------------------------------------- + vim.api.nvim_create_autocmd("BufWritePre", { desc = "Format buffer", group = vim.g.dotfiles.augroup, - callback = on_format, + callback = format_buffer, }) vim.api.nvim_create_user_command("FormatToggle", toggle_format, { desc = "Toggle format on save" }) |
