aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorSteven Arcangeli <506791+stevearc@users.noreply.github.com>2023-11-06 21:16:22 -0800
committerGitHub <noreply@github.com>2023-11-06 21:16:22 -0800
commit161d95bfbb1ad1a2b89ba2ea75ca1b5e012a111e (patch)
tree348d8c1c47005d539d07250bf11fce8c7bb56503 /lua
parentdcbe650bd4811cefe5a885fafb6309c7d592bda6 (diff)
fix: nonzero exit code on :wq (#176)
Diffstat (limited to 'lua')
-rw-r--r--lua/conform/init.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lua/conform/init.lua b/lua/conform/init.lua
index 32f24eb..50ae6ba 100644
--- a/lua/conform/init.lua
+++ b/lua/conform/init.lua
@@ -85,6 +85,7 @@ M.setup = function(opts)
opts.format_on_save = {}
end
vim.api.nvim_create_autocmd("BufWritePre", {
+ desc = "Format on save",
pattern = "*",
group = aug,
callback = function(args)
@@ -106,6 +107,16 @@ M.setup = function(opts)
end
end,
})
+ vim.api.nvim_create_autocmd("VimLeavePre", {
+ desc = "conform.nvim hack to work around Neovim bug",
+ pattern = "*",
+ group = aug,
+ callback = function()
+ -- HACK: Work around https://github.com/neovim/neovim/issues/21856
+ -- causing exit code 134 on :wq
+ vim.cmd.sleep({ args = { "1m" } })
+ end,
+ })
end
if opts.format_after_save then
@@ -115,6 +126,7 @@ M.setup = function(opts)
local exit_timeout = 1000
local num_running_format_jobs = 0
vim.api.nvim_create_autocmd("BufWritePost", {
+ desc = "Format after save",
pattern = "*",
group = aug,
callback = function(args)
@@ -156,6 +168,7 @@ M.setup = function(opts)
})
vim.api.nvim_create_autocmd("BufWinLeave", {
+ desc = "conform.nvim store changedtick for use during Neovim exit",
pattern = "*",
group = aug,
callback = function(args)
@@ -166,6 +179,7 @@ M.setup = function(opts)
})
vim.api.nvim_create_autocmd("VimLeavePre", {
+ desc = "conform.nvim wait for running formatters before exit",
pattern = "*",
group = aug,
callback = function()
@@ -182,6 +196,9 @@ M.setup = function(opts)
local log = require("conform.log")
log.warn("Delayed Neovim exit by %dms to wait for formatting to complete", elapsed)
end
+ -- HACK: Work around https://github.com/neovim/neovim/issues/21856
+ -- causing exit code 134 on :wq
+ vim.cmd.sleep({ args = { "1m" } })
end,
})
end