From b94ace41d95890ece33b5dc9517d255d7cbd3035 Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Fri, 20 Mar 2026 12:48:46 -0400 Subject: [PATCH] neovim: Fix zls formatting hook --- neovim/lua/plugins/ide.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/neovim/lua/plugins/ide.lua b/neovim/lua/plugins/ide.lua index 3740593..16b8c16 100644 --- a/neovim/lua/plugins/ide.lua +++ b/neovim/lua/plugins/ide.lua @@ -12,9 +12,19 @@ vim.api.nvim_create_autocmd("LspAttach", { -- Usually not needed if server supports "textDocument/willSaveWaitUntil". already_waits = client:supports_method("textDocument/willSaveWaitUntil") can_fmt = client:supports_method("textDocument/formatting") - -- But tsserver/ts_ls seems to have no other way of disabling formatting. - deny_fmt = client.name == "ts_ls" - if not already_waits and can_fmt and not deny_fmt then + + should_fmt = ({ + -- tsserver/ts_ls seems to have no other way of disabling formatting. + ["ts_ls"] = false, + -- zls doesn't seem to trigger the normal way. + ["zls"] = true, + })[client.name] + + if should_fmt == nil then + should_fmt = not already_waits and can_fmt + end + + if should_fmt then vim.api.nvim_create_autocmd("BufWritePre", { group = vim.api.nvim_create_augroup("jdkaplan.lsp", { clear = false }), buffer = args.buf,