From 90816e3725058b393f6b8256974b9de8bcc05add Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 10 Aug 2023 09:43:12 -0400 Subject: [PATCH] feat(cpp): only load `clangd_extensions` when `clangd` attaches --- lua/astrocommunity/pack/cpp/init.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/astrocommunity/pack/cpp/init.lua b/lua/astrocommunity/pack/cpp/init.lua index 34d95f96a..9d0a82f75 100644 --- a/lua/astrocommunity/pack/cpp/init.lua +++ b/lua/astrocommunity/pack/cpp/init.lua @@ -18,7 +18,20 @@ return { }, { "p00f/clangd_extensions.nvim", - ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + init = function() + -- load clangd extensions when clangd attaches + local augroup = vim.api.nvim_create_augroup("clangd_extensions", { clear = true }) + vim.api.nvim_create_autocmd("LspAttach", { + group = augroup, + desc = "Load clangd_extensions with clangd", + callback = function(args) + if assert(vim.lsp.get_client_by_id(args.data.client_id)).name == "clangd" then + require "clangd_extensions" + vim.api.nvim_del_augroup_by_id(augroup) + end + end, + }) + end, }, { "Civitasv/cmake-tools.nvim",