X-Git-Url: https://git.madduck.net/etc/lazyvim.git/blobdiff_plain/f0708014115af01e71566bf9d49fe821047c162d..4a4d8b8ec77a9edb85b9ecba820238451fd42c97:/.config/lazyvim/after/ftplugin/mail.lua diff --git a/.config/lazyvim/after/ftplugin/mail.lua b/.config/lazyvim/after/ftplugin/mail.lua index 176382c..52dc767 100644 --- a/.config/lazyvim/after/ftplugin/mail.lua +++ b/.config/lazyvim/after/ftplugin/mail.lua @@ -27,7 +27,29 @@ vim.opt_local.commentstring = "> %s" -- commenting means quoting in mails vim.api.nvim_create_autocmd({ "BufWrite" }, { buffer = 0, group = vim.api.nvim_create_augroup("squashemptylines", { clear = true }), - command = [[%s/\v(\n)\n+$/\1/ge]], + callback = function() + local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) + local ret = {} + local count = 0 + local squash = false + for _, line in ipairs(lines) do + if line == "" then + if not squash then + squash = true + table.insert(ret, line) + else + count = count + 1 + end + else + squash = false + table.insert(ret, line) + end + end + if count > 0 then + vim.notify("Squashed " .. count .. " empty line(s)") + end + vim.api.nvim_buf_set_lines(0, 0, -1, false, ret) + end, }) -- }}} @@ -69,7 +91,7 @@ local function profile_keymap(key, profile) ) end -profile_keymap("F1", "official") +profile_keymap("F1", "main") profile_keymap("F2", "pobox") profile_keymap("F3", "tahi") profile_keymap("F4", "toni") @@ -79,7 +101,6 @@ profile_keymap("F7", "siby") profile_keymap("F8", "debian") profile_keymap("F9", "uniwh") profile_keymap("F10", "mtfk") -profile_keymap("F11", "sudetia") profile_keymap("F12", "default") -- }}} profiles