summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiro Okuno <[email protected]>2022-06-06 18:50:24 +0900
committerGitHub <[email protected]>2022-06-06 11:50:24 +0200
commitf778a38c31daf53db42c4187faf08fcd004d441b (patch)
tree05c2cce63725f0d01d1805ea1aeeff57486f38cc
parent7c53bd64c570c1e7151090eb758a17211f45965d (diff)
fix(autocmds): toggle format-on-save properly (#2659)
-rw-r--r--lua/lvim/core/autocmds.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua
index 0ca21439..20716e83 100644
--- a/lua/lvim/core/autocmds.lua
+++ b/lua/lvim/core/autocmds.lua
@@ -118,11 +118,11 @@ function M.configure_format_on_save()
end
function M.toggle_format_on_save()
- local exists, _ = pcall(vim.api.nvim_get_autocmds, {
+ local exists, autocmds = pcall(vim.api.nvim_get_autocmds, {
group = "lsp_format_on_save",
event = "BufWritePre",
})
- if not exists then
+ if not exists or #autocmds == 0 then
M.enable_format_on_save()
else
M.disable_format_on_save()