From 59dfc51e93de241444b0416098e76f7bdcd76e10 Mon Sep 17 00:00:00 2001 From: BakerNet Date: Tue, 19 Dec 2023 16:05:49 -0800 Subject: [PATCH] async autoformat only for python --- lua/plugins/lsp.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 6495709..6fc149d 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -56,8 +56,16 @@ local setup_autoformat = function() return end + local async = false + -- black is too slow - only worth with async + local venv_path = os.getenv('VIRTUAL_ENV') + if venv_path ~= nil then + async = true + end + + vim.lsp.buf.format { - async = true, -- black takes forever... we'll see + async = async, filter = function(c) return c.id == client.id end,